ole90
06-18-2008, 04:12 PM
Hey guys,
I'm very new to JavaScript programming and so I wrote this function today to try and change the image with a simple click of a button. Code:
<html>
<head>
<title>Testing Javascript</title>
<script language="JavaScript" type="text/javascript">
<!--
function changeimage() {
var img = document.getElementById("Myimage");
img.src="newimage.png";
}
// -->
</script>
</head>
<body>
<img src="myimage.png" name="Myimage" ID="Myimage">
<form name="changeimage">
<input type="button" value="Change Image" onClick="changeimage();">
</form>
</body>
</html>
But for some reason this does nothing :X Could someone explain what is wrong :X? Thanks!
I'm very new to JavaScript programming and so I wrote this function today to try and change the image with a simple click of a button. Code:
<html>
<head>
<title>Testing Javascript</title>
<script language="JavaScript" type="text/javascript">
<!--
function changeimage() {
var img = document.getElementById("Myimage");
img.src="newimage.png";
}
// -->
</script>
</head>
<body>
<img src="myimage.png" name="Myimage" ID="Myimage">
<form name="changeimage">
<input type="button" value="Change Image" onClick="changeimage();">
</form>
</body>
</html>
But for some reason this does nothing :X Could someone explain what is wrong :X? Thanks!