eduard Posted June 19, 2012 Share Posted June 19, 2012 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 More sharing options...
Guest So Called Posted June 19, 2012 Share Posted June 19, 2012 missing } Link to comment Share on other sites More sharing options...
justsomeguy Posted June 19, 2012 Share Posted June 19, 2012 Literal values in the place of parameters. I suspect you're also using the wrong ID. Link to comment Share on other sites More sharing options...
Guest So Called Posted June 19, 2012 Share Posted June 19, 2012 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 More sharing options...
eduard Posted June 19, 2012 Author Share Posted June 19, 2012 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 More sharing options...
justsomeguy Posted June 19, 2012 Share Posted June 19, 2012 Winner! Link to comment Share on other sites More sharing options...
Guest So Called Posted June 19, 2012 Share Posted June 19, 2012 (edited) 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 June 19, 2012 by So Called Link to comment Share on other sites More sharing options...
Guest So Called Posted June 19, 2012 Share Posted June 19, 2012 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 More sharing options...
eduard Posted June 21, 2012 Author Share Posted June 21, 2012 I´ll leave these fora for a while, because I urgently need work, but I´ll certainly come back!Thanks so far! Link to comment Share on other sites More sharing options...
thescientist Posted June 21, 2012 Share Posted June 21, 2012 I have absolutely no idea how you're calling your function and it will be interesting to hear the details. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now