Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change image onLoad (tab menu ON state)

Status
Not open for further replies.

marthirial

IS-IT--Management
Jan 29, 2005
20
0
0
US
I have a tab menu made out of tables and images, all the images are in "off" state. What I want to achieve is that one the user enters a page (not by clicking the tab menu) it will, onLoad, change one of the tabs in the menu to the ON status.

I know I need a trigger for the javascript to know that the image has to change, so I was thinking on using a word in the META keywords of the page; Pseudo code follows:

Page Loads
Function read META KEYWORDS
IF META TAG = "products" THEN change tab2_off.gif into tab2_on.gif

Obviously using META KEYWORDs is optional, if there is any other method to get a value out of a page, much better.

Thanks for your help with this task.
 

If you are going to have different code on each page to determine the button to switch on, why not just have different code to do the actual switching. To clarify, instead of having two pieces of code:

(pseudo code)
Code:
<meta sometag="products">

...

<body onload="if (sometag == 'products') switchButtonOn('products');">

Why not just have the one:

(pseudo code)
Code:
<body onload="switchButtonOn('products');">

Or have I misunderstood what you are asking?

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Dan:

The page with the 6-tab menu is a template and its content dynamic. Basically in my cutting-corners approach I want to "read" something from this dynamic content that could trigger a function into changing the corresponding tab into ON state.

Javascript code is needed. Thanks
 
Marthirial,

I did something similar recently, but I used CSS to set the background color of the current link/page, but I would think you could use similar javascript logic if you had access to some sort of identifier like a category id or something (you said the pages were dynamic).

Anyway, this is the thread that I'm referring to. Maybe it will spark an idea for you:

 
Just to clarify, I used javascript to determine the current page and CSS to highlight that link.
 
Thanks for the link, but I don't think that could resolve my issue here.

The idea is that something in the content of the dynamic text can become the variable that the javascript in the template will use to decide which image to show as ON in the tabbed menu.



 
Well, I was thinking that maybe you had a dynamic url that you could extract an id from. If the dynamic portion is not set in the url (not passed by querystring), then you'll need to use a server-side scripting language to extract the id (or other dynamic qualifiers) and specify the specific html code from there, depending on what was "posted".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top