[thelist] best way to do dynamic tabs in PHP

Tom Dell'Aringa pixelmech at yahoo.com
Tue Jan 21 19:58:01 CST 2003

Hey all,

I have a site with your typical tabbed navigation, with rollovers.
Each tab is an image with a link of course, just like this:

<a href="parties.php" onmouseover="rollOver('parties', 'on');"
onmouseout="rollOver('parties', 'off');">
<img src="/_images/parties_off.gif" width="115" height="36"
alt="parties" border="0" align="absbottom" name="parties" />

and there are 6. When a user is on the correct page, I want the tab
to show a THIRD state (not the regular or the rollover state) that
matches the background, so you know what page you are on. The way I
have done this in the past is:

// get page name, assume 'parties.php'

$curpage = basename($_SERVER['SCRIPT_NAME']);

// test each tab to see if it is the right page

if($curpage == "parties.php")
  // show 'selected' parties tab with no rollover state
  // show regular parties tab with rollover state

And I would do this for each of the six images. This seems like lots
of code, and I'm thinking there is a better way to do this, but I'm
not sure what it is. I do NOT want to do something like numbering my
images instead of naming them and using an array, but I'm sure thats
not the only way.



var me = tom.pixelmech.webDeveloper();

[Making A Commercial Case for Adopting Web Standards]

Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.

More information about the thelist mailing list