msmid
asked on
javascript onClick change div
Hello,
I have two links (images), first for backward second for forward.
I would linke to change (n) divs back and forward with this two buttons. Example on http://www.otteybypamp.com/en/majcka.asp?menuid=majcka, but there I change only pictures, now I need the layers.
Thank you,
Mitja
I have two links (images), first for backward second for forward.
I would linke to change (n) divs back and forward with this two buttons. Example on http://www.otteybypamp.com/en/majcka.asp?menuid=majcka, but there I change only pictures, now I need the layers.
Thank you,
Mitja
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can also replace those rules:
document.getElementById("i mgDiv"+Div Current).s tyle.displ ay = "none";
and
document.getElementById("i mgDiv"+Div Current).s tyle.displ ay = "block";
with:
if(document.all)
document.all("imgDiv"+DivC urrent).st yle.displa y = "none";
else
document.getElementById("i mgDiv"+Div Current).s tyle.displ ay = "none";
and
if(document.all)
document.all("imgDiv"+DivC urrent).st yle.displa y = "block";
else
document.getElementById("i mgDiv"+Div Current).s tyle.displ ay = "block";
document.getElementById("i
and
document.getElementById("i
with:
if(document.all)
document.all("imgDiv"+DivC
else
document.getElementById("i
and
if(document.all)
document.all("imgDiv"+DivC
else
document.getElementById("i
ASKER
Thank you johanmulder.
Mitja
Mitja
a slight modification to the code, should make it work in both popular browsers ( as follows : )#
The script takes in the div id, as the one to show, if you need more than two divs, you would just 'hide' more of them, in the javascript block, then make visible the one past into the equation
<script language="javascript">
var visdiv = 'first';
function SwapDiv(div)
{
if (div != visdiv)
{
document.getElementById(di
document.getElementById(vi
visdiv = div;
}
}
</script>
<div id="second" style="position:absolute; top:0px; left:0px; visibility:hidden;">
second div
</div>
<img src="back.gif" width="32" height="32" alt="" border="0" onclick="SwapDiv('first')"
<img src="forward.gif" width="32" height="32" alt="" border="0" onclick="SwapDiv('second')