Jump to content

Javascript swapimage HELP


abdoel

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/277205-javascript-swapimage-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.