Forum Moderators: open

Message Too Old, No Replies

Toggle script add-on

have script remember the toggle on refresh

         

salo

6:19 pm on Jul 22, 2005 (gmt 0)

10+ Year Member



I have a small toggle script I've been using and can't seem to figure out how to make it remember the toggle. So for example, if I toggle on the second page and then hit refresh on the browser, it would remember to keep the second page toggle on.

hope that makes sense,
here is the javascript on top:

<script language="JavaScript" type="text/javascript">
<!--
var zxcPageAry=new Array();

function zxcInit(id){
zxcDivs=document.getElementsByTagName('DIV');
for (zxc0=0;zxc0<zxcDivs.length;zxc0++){
if (zxcDivs[zxc0].className=='Page'){
zxcPageAry[zxcPageAry.length]=zxcDivs[zxc0];
zxcDivs[zxc0].style.display='none';
}
}
zxcPageAry[0].style.display='block';
zxcPageAry[0].style.visibility='visible';
}

function ShowPage(nu){
for (zxc0=0;zxc0<zxcPageAry.length;zxc0++){
zxcPageAry[zxc0].style.display='none';
}
zxcPageAry[nu].style.display='block';
zxcPageAry[nu].style.visibility='visible';
}

//-->
</script>

i have it onload on the body tag, and in the html:

<div class="Page"><span onclick="ShowPage(0);"><img src="images/button_viewdetails.on.gif" width="116" height="20"></span>
<span onclick="ShowPage(1);"><img src="images/button_formdefaults.off.gif" width="150" height="20"></span>
<span onclick="ShowPage(2);"><img src="images/button_sessionhistory.off.gif" width="105" height="20"></span>
<span onclick="ShowPage(3);"><img src="images/button_dataadmin.off.gif" width="80" height="20"></span></div>

<div class="Page"><span onclick="ShowPage(0);"><img src="images/button_viewdetails.off.gif" width="116" height="20"></span>
<span onclick="ShowPage(1);"><img src="images/button_formdefaults.on.gif" width="150" height="20"></span>
<span onclick="ShowPage(2);"><img src="images/button_sessionhistory.off.gif" width="105" height="20"></span>
<span onclick="ShowPage(3);"><img src="images/button_dataadmin.off.gif" width="80" height="20"></span></div>

and so on for the other two pages...

Any suggestions?

Rambo Tribble

2:55 am on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can think of only two things that reliably persist on refresh, cookies and window.name property.