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>

Edited by abdoel
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.