F
Ferd Flintstone
I know this should be really simple but I've tried for hours, can anyone
help?
I'm trying to write JavaScript that will change an image (.gif) when user
clicks a button. Have included all the script its not long. It's coppied
from a book I'm reading to try to teach myself JavaScript but just wont
work. When tested in a Browser the first Image is Displayed correctly
("images/summer-tree") but just get error when button is clicked.
Error is Line 18. Char 1, Object Expected. (its as if the function
"ChangeImage" is not recognised.)
Here is my Code:
<HEAD>
<TITLE>IMG example</TITLE>
<SCRIPT LANGUAGE = Javascipt>
function ChangeImage(){document.img1.src =
"images/winter-tree.gif";document.form1.tree.value = "Can't wait for
Summer.";} // EoFn
</SCRIPT>
</HEAD>
<BODY>
<CENTER><FONT SIZE=-1>
<B>The<I> Ash Tree </I>in Summer & Winter
</FONT>
<P><IMG NAME="img1"
SRC="images/summer-tree.gif" >
<FORM method=" " action=" " NAME="forml">
<FONT SIZE=-2>
<INPUT TYPE=button NAME="tree"
VALUE="The Winter look"
onClick="ChangeImage()">;
</FONT>
<BR>
</FORM>
<ADDRESS>Image-Ex14.htm</ADDRESS>
</CENTER>
</BODY>
Thanks for any help
Please reply to group
Fred
help?
I'm trying to write JavaScript that will change an image (.gif) when user
clicks a button. Have included all the script its not long. It's coppied
from a book I'm reading to try to teach myself JavaScript but just wont
work. When tested in a Browser the first Image is Displayed correctly
("images/summer-tree") but just get error when button is clicked.
Error is Line 18. Char 1, Object Expected. (its as if the function
"ChangeImage" is not recognised.)
Here is my Code:
<HEAD>
<TITLE>IMG example</TITLE>
<SCRIPT LANGUAGE = Javascipt>
function ChangeImage(){document.img1.src =
"images/winter-tree.gif";document.form1.tree.value = "Can't wait for
Summer.";} // EoFn
</SCRIPT>
</HEAD>
<BODY>
<CENTER><FONT SIZE=-1>
<B>The<I> Ash Tree </I>in Summer & Winter
</FONT>
<P><IMG NAME="img1"
SRC="images/summer-tree.gif" >
<FORM method=" " action=" " NAME="forml">
<FONT SIZE=-2>
<INPUT TYPE=button NAME="tree"
VALUE="The Winter look"
onClick="ChangeImage()">;
</FONT>
<BR>
</FORM>
<ADDRESS>Image-Ex14.htm</ADDRESS>
</CENTER>
</BODY>
Thanks for any help
Please reply to group
Fred