Jump to content

Wrong ....?


eduard
 Share

Recommended Posts

What´s wrong? <script type="text/javascript"> function swapImage("eduard","eduard2") { elm = document.getElementById("eduard.JPG"); elm.src = "eduard2.JPG"</script>

Link to comment
Share on other sites

Guest So Called

Now that you mention it I'd bet money he's got the wrong ID. Unfortunately I'd find no takers for that bet. :) Go ahead Eduard and post your <IMG> code.

Link to comment
Share on other sites

Now that you mention it I'd bet money he's got the wrong ID. Unfortunately I'd find no takers for that bet. :) Go ahead Eduard and post your <IMG> code.
<img id="eduard" src="eduard.JPG" alt="img Eduard Lid">
Link to comment
Share on other sites

Guest So Called

Okay I'll take a shot and I don't even know JavaScript hardly at all.

<script type="text/javascript">function swapImage(imageId,newImage){elm = document.getElementById(imageId);elm.src = newImage;}</script>

It's what JSG said about literals. I've substituted variables for your literals. I have absolutely no idea how you're calling your function and it will be interesting to hear the details.

Edited by So Called
Link to comment
Share on other sites

Guest So Called

Alternative approach:

<script type="text/javascript">function swapImage(){elm = document.getElementById("eduard");elm.src = "eduard2.JPG"</script>;}

You didn't say how you're triggering your script so we on the forum can only speculate what you're trying to do. One problem with writing code, it usually has to be exactly right, or it's completely wrong. Once you get rid of the syntax errors the damned computer (server, browser, etc.) insists on doing exactly what you told it to do, not what you wanted it to do.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...