AmmO
08-06-2008, 10:06 AM
I have a main image on a page im creating, i would like to change it using a button that the user selects. There is a maximum 3 image changes plus the original image that is displayed when the page loads.
I would like it so that when you click on the button image A, turns into image B and if you click again you get back to image A.
now i have the code for this already and have it working
<script language="JavaScript">
<!--
var x = 0;
function chngImg()
{
if (x == 0)
{
x = 1;
document.getElementById("image a").src = image b.gif';
}
else
{
x = 0;
document.getElementById("image a").src = 'image a.gif';
}
}
//-->
</script>
and heres the html tag
<input type="button" value="Show image b" onclick="chngImg()" name="imgName"></input>
The problem im having is modifying the same javascript to work for image C and D
any help would be most highly appreciated.
I would like it so that when you click on the button image A, turns into image B and if you click again you get back to image A.
now i have the code for this already and have it working
<script language="JavaScript">
<!--
var x = 0;
function chngImg()
{
if (x == 0)
{
x = 1;
document.getElementById("image a").src = image b.gif';
}
else
{
x = 0;
document.getElementById("image a").src = 'image a.gif';
}
}
//-->
</script>
and heres the html tag
<input type="button" value="Show image b" onclick="chngImg()" name="imgName"></input>
The problem im having is modifying the same javascript to work for image C and D
any help would be most highly appreciated.