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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to change a button image

Status
Not open for further replies.

doogle

Technical User
Feb 8, 2001
6
GB

Hi there, I'm trying to create a button from a graphic (easy! I hear you say just use <A href=&quot;mypage.htm&quot;>
<IMG SRC=&quot;button.gif&quot;></A> )

But what I'd like to do is have the button image toggle to another image after it has been pressed. Then the button keep that image until it gets pressed again (when it should return to the first image).

Basically it's going to be an on/off switch to load one page when you click 'on' (then the graphic changes) and another page when you click 'off' (and the graphic changes back). Simple huh?

Any ideas/seen it somewhere anyone?

Thanks for any help/advice,

- Doogle.
 
Set up a variable say on:

var on = 0;

onClick call a function which sets it to what it isn't, you know if it'1, --> 0...Then the rest of the function tests the variable and sets the src depending on what that variable is now.

Or you could count clicks, using even odd numbers, that isnt the problem!
The problem you will have is if you change pages, the value will be reset, so you would have to write it to a cookie, which you could do, or just make the button pop up a new window, there-by keeping the variable 'alive'.

H.T.H

Ben
&quot;Lyin, cheatin, hu-urtin, that's a-all you seem to do-oo-oo&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top