SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why doesn’t IE remember dynamically changed values?

    Hello

    I am having an issue with IE that I was hoping someone could help me with. Here are the steps I am following.

    - click a link that calls JavaScript
    - dynamically change a hidden input value with JavaScript
    - submit a form
    - Once the 2nd page is loaded, I hit the back button to go back to the 1st page
    - IE does not remember the value that was dynamically changed

    If I do this scenario in FireFox, it works perfect but in IE, it does not retain a dynamically changed value. Have I implemented something incorrectly or is this an issue with the IE browser? Does someone know how I could implement this same logic in a way that works with both IE and FireFox?

    Here is an example to show what I am trying to do.

    First.htm
    Code:
    <html>
    <head>
    <script language="JavaScript">
    
    function go()
    {
       document.getElementById( "saveField" ).value = "N";
       document.save.submit();
    }
    
    </script>
    </head>
    
    <body>
    1st Page
    <br>
    <a href="javascript: go();">Go to Page 2</a>
    
    <form name="save" action="second.htm">
       <input type="hidden" id="saveField" name="saveField" value="Y" />
    </form>
    
    <script language="JavaScript">
       alert( "saveFiled = " + document.getElementById( "saveField" ).value);
    </script>
    
    </body>
    </html>
    Second.htm
    Code:
    <html>
    <head>
    </head>
    
    <body>
    Page 2
    </body>
    </html>

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    history

    I think this is a browser "feature". Different browsers treat the "history" differently. This affects what happens when you use the back button.

    Solution? Maybe a Cookie?

  3. #3
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was thinking of using a session cookie but I was hoping I was just missing a simple tag on the form or something easy like that.


Bookmarks

Posting Permissions

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