abdoel Posted April 23, 2013 Share Posted April 23, 2013 (edited) Hi there, i'm busy with a project but know im stuck at some point. What i want to do is, when someone presses the home button it changes his color. How I wanted to do is swap from image 1 (white) to image 2 (blue). So the person can see on which page he/she is. But when i put this code into the website, it wont show nothing. When i press 2 times it will show the blue image. And when i press many times you see the white and blue image swapping. But it won't stand on the white image, only on the blue image Here is the code i use. --> <a href='' "<?php echo $this->createUrl("/admin/survey/sa/index"); ?>" onclick="edit()"><img id="img1" onclick="imageChange(this)"'<?php echo $sImageURL;?>home.png' alt='<?php $clang->eT("Default administration page");?>' /><script type="text/javascript">{var img1 = "/LimeSurvey/styles/scanyours/images/home.png";var img2 = "/LimeSurvey/styles/scanyours/images/home1.png";}{var imageChoice = 1;}function imageChange(element) {if (imageChoice == 1){element.src = img2;imageChoice = 2;}else if (imageChoice == 2) {element.src = img1;imageChoice = 1;}}</script></a> Edited April 23, 2013 by abdoel Quote Link to comment https://forums.phpfreaks.com/topic/277205-javascript-swapimage-help/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.