Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object expected error 1

Status
Not open for further replies.

fluxdemon

MIS
Joined
Nov 5, 2002
Messages
89
Location
US
I am getting an object expected error when I try to call function first() from a button. If I put the function action inline on the onClick it works. What am I doing wrong?!?!

<html>

<script language=&quot;JavaScript&quot;
<!--
function first()
{
document.images.test.src = &quot;2.jpeg&quot;;
}
-->
</script>

<body>

<input type=&quot;button&quot; onClick=&quot;first();&quot; value=&quot;test&quot;>

<img name=&quot;test&quot; src=&quot;.\1.jpeg&quot;>

</body>
</html>
 
i hate that error... i've gotten it plenty 'o' times. Try this to swap the images on the button click.


<html>
<head>
<title>hi</title>
<script language=&quot;JavaScript&quot;>
function fncswap()
{
document.getElementById('myImage').src=&quot;Em.jpg&quot;;
}
</script>
</head>
<body>
<input type=&quot;button&quot; value=&quot;go&quot; onClick=&quot;fncswap();&quot;>
<img id=&quot;myImage&quot; src=&quot;Kim.jpg&quot;>
</head>
</html>

Later,
Greelmo
 
oh, sorry... the 'Em.jpg' and 'Kim.jpg' are just some pics i used to test it. Just switch 'em with your pictures.

Later,
Greelmo
 
Both ways work.... I just forgot to end brace on the top <script> tag. Thanks for you help!
 
oh haha, didn't catch that... i hate how little things slip like that.

Later,
Greelmo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top