wynton_ca
10-29-2003, 02:38 PM
I need to amend the current script,....which swaps out an image based on an if/else statement correlating to the image.....to also include a rollover. The image swap is controlled by an onclick event, whereas the rollover needs to be controlled via onmouseover event. Below is the code. I've been racking my head trying to figure out how to get this to work correctly. Because the images are client side only, I cant just specify within the anchor tag or the image tag the rollover. In my head it needs to go within the governing function.
<html>
<head>
<script language="javascript">
//images for the function
swap1 = "btn_videos.gif";
swap2 = "btn_videos_over.gif";
function chng(c_img) {
if (c_img.src.indexOf(swap1)!= -1) {
c_img.src = swap2;
//alert("if");
}
else {
c_img.src = swap1;
//alert("else");
}
}
</script>
</head>
<body>
<a href="#"><img src="btn_videos.gif" width="113" height="27" alt="Show/Hide Details" border="0" onmouseover="rollover()" onclick="chng(this)" name="img1" /></a>
</body>
</html>
Any help, and suggestions or solutions are much much appreciated!
Thanks
<html>
<head>
<script language="javascript">
//images for the function
swap1 = "btn_videos.gif";
swap2 = "btn_videos_over.gif";
function chng(c_img) {
if (c_img.src.indexOf(swap1)!= -1) {
c_img.src = swap2;
//alert("if");
}
else {
c_img.src = swap1;
//alert("else");
}
}
</script>
</head>
<body>
<a href="#"><img src="btn_videos.gif" width="113" height="27" alt="Show/Hide Details" border="0" onmouseover="rollover()" onclick="chng(this)" name="img1" /></a>
</body>
</html>
Any help, and suggestions or solutions are much much appreciated!
Thanks