...

View Full Version : Dynamic Style changes not surviving back button



charon
07-08-2006, 02:43 AM
Hi,

I have two radio buttons with two options,YES and NO. When the user click on YES, I use some JavaScript to display some text, as below:

obj.style.visibility='visible';

Or if they click No I collapse it again with a style change:

obj.style.visibility='hidden';

So, there has two scenarios:

1.) By default value is YES so the text is 'Visible', when user click on NO (the text will be hided) and submit by proceed to another page and When they then click the browser Back Button to return to the first page, the text is "visible'.

2.) By default, the text is "hide" and it will be reflected when user click on "YES", but when user proceed to another page and When they then click the browser Back Button to return to the first page, the text is "hide".

pls advise...

glenngv
07-08-2006, 06:36 AM
On onload of the page, set the visibility of the text to visible if YES is checked, otherwise, set it to hidden. In this way, when the page is loaded again when BACK button is pressed, the onload function will display or hide the text appropriately.

charon
07-10-2006, 10:01 AM
Hi,

We have tried Onload before, but cannot. The obj.style.visibility='visible'; not reflected. But we managed to get the alert. So really wonder why???

glenngv
07-10-2006, 06:54 PM
I cannot see what's wrong if I can't see the code. Post the code and the related HTML.

charon
07-14-2006, 12:07 PM
I have created a simple test page to explain my problem.

1.) I call onload to hide a table with Heloo text
2.) Please click on the "Click" button and the "table with Heloo text" will be display
3.) After that try to click on "Submit" button to proceed to next page and back to the page. You can see that the "table with Heloo text" will be disappear.

What I want is once the user click on the "Click" button and submit to next page, after back, the "table with Heloo text" will be displayed as it is.

pls advise.....

glenngv
07-14-2006, 06:36 PM
Try this. I edited the file you posted.


<%@ LANGUAGE="VBSCRIPT" %>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
<script language="javascript">
function testmenu(visibility)
{
var obj = document.getElementById("mymenu");
obj.style.left = "50px";
obj.style.top = "255px";
if (visibility){ //called from radio button
obj.style.visibility = visibility;
}
else { //called onload, set visibility accdg to currently checked radio button
if (document.getElementById("radShow").checked) {
obj.style.visibility = document.getElementById("radShow").value;
}
else {
obj.style.visibility = document.getElementById("radHide").value;
}
}

}

</Script>
</HEAD>
<BODY onload="testmenu('')">
<br>
<br>
<strong> </strong>
<form method="post" action="xmlhttp.asp">
<div id="mymenu">
<table width="445" border="1" cellspacing="0" cellpadding="2">
<tr>
<td>Hellooooo</td>
</tr>
</table>
</div>
<p><br>
<br>
<input type="submit" name="Submit" value="Submit">
<input type="hidden" name="v1" value="value1">
<input type="hidden" name="v1" value="value2">
<input type="hidden" name="v1" value="value3">
<input type="hidden" name="v1" value="value4">
&nbsp;&nbsp;
<input type="radio" name="rad" id="radShow" value="visible" onclick="testmenu('visible')" checked="checked" /><label for="radShow">Show</label>
<input type="radio" name="rad" id="radHide" value="hidden" onclick="testmenu('hidden')" /><label for="radHide">Hide</label>
</p>
</form>
</BODY>
</HTML>

charon
07-15-2006, 03:28 AM
Glenn,

Great!!! Thanks so much. This is exactly what I want.

charon
07-15-2006, 03:42 AM
Glenn,

Great!!! Thanks so much. This is exactly what I want.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum