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 6 of 6
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    47
    Thanks
    5
    Thanked 1 Time in 1 Post

    Form data disappears after page refresh

    I am using the following code to refresh a window that has an HTML form on it:
    window.opener.location.reload();

    When the page is refreshed, the data disappears.
    Is there a way to refresh the page, while keeping the form data?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Do you mean keep the data the user just entered? If so, you need to save the user entries in the session or database when the popup is loaded. You need to explain a bit more to get complete reply.
    Glenn
    ____________________________________

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

  • #3
    New Coder
    Join Date
    May 2007
    Posts
    47
    Thanks
    5
    Thanked 1 Time in 1 Post
    Yes, that is what I mean. The form data may not have been submitted at the time of the refresh.

    I have a window (#1) with a form. #1 has a link to pop up another window (#2) with another form. When the form on #2 is completed, #1 is refreshed.

    My project is a combination of ASP and JS. I understand session variables in ASP, which are kept on the server side. I'm guessing that JS saves the values on the client side?

    There was a time, when you could enter data into a form and press the F5 button to refresh, and the form data would still be there. This does not appear to be the case in the newest versions of Firefox and IE.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Set the values of the fields in form #1 to corresponding session variables. When session variables are not yet set (first load of the form), the field would be empty (this is fine).
    Code:
    <input type="text" name="txt1" value="<%=session("txt1")%>" />
    When link is clicked, submit form #1 to a popup window.
    Code:
    function createPoup(popupName){
       var w=window.open("", popupName, "width=500, height=400, resizable=1");
       w.focus();
       return true;
    }
    ...
    <form name="frm" method="post" action="form2.asp" target="popup" onsubmit="return createPopup(this.target);">
    ...
    <input type="submit" name="btnSubmit" value="Submit" />
    </form>
    In form #2 page, save the user inputs to session variables.
    Code:
    <%
    session("txt1") = request.form("txt1")
    ...
    %>
    When form #1 is reloaded, session variables are already set, so the fields would have the values the user entered.
    Glenn
    ____________________________________

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

  • #5
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,444
    Thanks
    11
    Thanked 598 Times in 578 Posts
    you might like:
    http://msdn.microsoft.com/workshop/a...asp?frame=true

    for 4/5 of you users anyway...

    you can store/load them in a cookie as well, or serialize up to 2kb in your querystring being passed to the popup.

  • #6
    New Coder
    Join Date
    May 2007
    Posts
    47
    Thanks
    5
    Thanked 1 Time in 1 Post
    Thank you for your solutions. I believe, however, that both of the solutions provided assume the form is being submitted before the popup. This isn't the case. They may have half-completed the form, then needed to view the popup, before submitting.

    At this point the issue is moot with this project, as we ended up going a different route anyway.

    Thank you for your assistance.


  •  

    Posting Permissions

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