Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    317
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic Style changes not surviving back button

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

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    317
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Onload can't solve my problem

    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???

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I cannot see what's wrong if I can't see the code. Post the code and the related HTML.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    317
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Test Page

    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.....
    Attached Files Attached Files
    Last edited by charon; 07-14-2006 at 12:09 PM.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Try this. I edited the file you posted.
    Code:
    <%@ 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>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Posts
    317
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Glenn,

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

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Posts
    317
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Glenn,

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •