View Single Post
Old 03-25-2012, 11:37 PM   PM User | #1
Qwerti
New to the CF scene

 
Join Date: Mar 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Qwerti is an unknown quantity at this point
Macintosh Why doesn't this JavaScript code work?

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Image Changer</title>
  <style type="text/css">
body {background-color:blue;}
  </style>
  <script type="JavaScript">
function ImgChange()

{ if (document.getElementByID("QWERT").src=="img1")
{document.(getElementByID("QWERT").src="img2"};
else if( document.getElementByID("QWERT").src=="img2")
{document.getElementByID("QWERT").src="img1"};
}
  </script>
</head>
<body>
<form> <input type="button" value="Change Image" onclick="ImgChange()"
 name="QwertButton"></form>
<img src="img1" title="QWERT" alt="Image 1" id="QWERT">

</body>
</html>
It's supposed totoggle an image when a button is pressed, but the image stays the same instead. And by the way, I tested the code on a 366 MHz iBook Clamshell on Classilla.
Qwerti is offline   Reply With Quote