PDA

View Full Version : img change on click help



Swearwolf
07-02-2008, 03:22 PM
Hi this is one thing im not good at. I want the image that is clicked to open the submenu, which works, but when that menu is opened (i.e when image is clicked) i want it to change to another pic, and change back when the submenu is closed.


<img src="1PNG" onclick="SwitchMenu('sub1')" width="189" height="26" img src="2.PNG"><br>
<span class="submenu" id="sub1">
- Home<br>
- What's New<br>
</span>

+rep thanks !!

Jme
07-02-2008, 06:43 PM
<img src="1PNG" name="1" onclick="SwitchMenu('sub1'); document.1.src='new.png';" width="189" height="26" img src="2.PNG"><br>
<span class="submenu" id="sub1">
- Home<br>
- What's New<br>
</span>

That should work? I don't know about changing it back, I'm useless with javascript.

Swearwolf
07-02-2008, 06:53 PM
nup. +rep for trying

MrCraig
07-02-2008, 09:33 PM
In head..


<script type="text/javascript">
function swim()
{
if(switchcount==0)
{
document.getElementById("1").src = 'IMAGE WHEN CLICKED';
switchcount = 1;
}
else
{
document.getElementById("1").src = 'ORIGINAL IMAGE';
switchcount = 0;
}
}
</script>



Then replace your code with this..


<img src="1PNG" onclick="SwitchMenu('sub1'); swim();" width="189" height="26" img src="2.PNG" id="1"><br>
<span class="submenu" id="sub1">
- Home<br>
- What's New<br>
</span>

Meti
09-02-2008, 06:22 PM
In head..


<script type="text/javascript">
function swim()
{
if(switchcount==0)
{
document.getElementById("1").src = 'IMAGE WHEN CLICKED';
switchcount = 1;
}
else
{
document.getElementById("1").src = 'ORIGINAL IMAGE';
switchcount = 0;
}
}
</script>



Then replace your code with this..


<img src="1PNG" onclick="SwitchMenu('sub1'); swim();" width="189" height="26" img src="2.PNG" id="1"><br>
<span class="submenu" id="sub1">
- Home<br>
- What's New<br>
</span>


I think he's right.. Lol. I dunno... +rep to you ;)

Want to hide these adverts? Register an account for free!