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

intype ="image" ... wont swap picture

Status
Not open for further replies.

bobrivers2003

Technical User
Oct 28, 2005
96
GB
I have a image for a button in a form. When the image is clicked I want the image to change. I have it working if the image is displayed as

<img name="IMG1" id="IMG1" src="images/on.gif" onClick="swapImage();"
alt="Auto Refresh">

however if the image in the form is displayed as

<input type="image" name="IMG1" id="IMG1" src="images/on.gif"
onClick="swapImage();" alt="Auto Refresh">


it wont work. I'm not sure how to send the js to <input type ="image" ... instead of <img src="....

The javascript:

intImage = 2;
function swapImage() {
switch (intImage) {
case 1:
form.IMG1.src = "images/on.gif"
intImage = 2
return(false);
case 2:
form.IMG1.src = "images/off.gif"
intImage = 1
return(false);
}
}


The form:

<form id="form" method="get">

<img name="IMG1" id="IMG1" src="images/on.gif" onClick="swapImage();"
alt="Auto Refresh">

</form>

Any help would be greatly appreciated


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top