SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    UK
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change a Refresh into a POST?

    Hello,

    I have a little problem with my javascript, if someone clicks refresh or F5 then the selections they have made are lost.

    Here is my test code: http://www.g7smy.myby.co.uk/select1.php

    Ovbiously, I can use PHP to gather the $_POST data using PHP, but that only returns the data that was last posted.

    My idea is that I can use <body onUnload='blah();'> to detect a refesh, and as the data is in hidden form fields so I can use that to fill in the missing bits. But my experiments so far have ended in confusion.

    Can anyone help?
    Thanks.

  2. #2
    SitePoint Addict markchivs's Avatar
    Join Date
    Oct 2004
    Location
    Malvern Hills, UK
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the web page is refreshed it's like resetting the page, you cant post any data at that point or store values in javascript or hidden fields that will be picked up when the page reloads.

    If someone wants to refresh the page why would you want to hold the data in the current state?

    The only way I can think of you doing it is by sending a xmlHTTP request to the server each time a users selection changes, but really what your trying to do here is a whole workd of pain and i'm a little lost as to why you would wnt to do it.

    Tell us what your trying to achieve



  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    UK
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by markchivs
    If someone wants to refresh the page why would you want to hold the data in the current state?
    So they don't lose the selections they have made on the page. See the link in my original message, make some selections and then refresh.

  4. #4
    SitePoint Zealot loupblanc's Avatar
    Join Date
    Nov 2004
    Location
    Edinburgh
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you're using php, try to convert your $_POST in a $_SESSION and have your fields set up as <input type="text" name="blah" value="<?=$_SESSION['blah']?>" />

    cheers

    -Jean-Loup


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
  •