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 5 of 5
  1. #1
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts

    Maintaining selected values when you click 'back'

    I've got a form. With some select boxes, and text inputs and all sorts of stuff like that. It submits to a page. That page has a "back" link on it - a simple javascript history.go type one. When you click it, you go back to the form. All the text inputs on the form have kept the values that you typed in. This is good. But only some of the select boxes have kept their selected values; the rest have reverted to the first value in their option list.

    This is in IE 6. In Firefox 1.0.4 none of the select boxes have kept their values. As far as I knew, you couldn't do what IE appears to be doing without scripting it.

    Why is IE keeping the selected values of some select boxes? What governs this behaviour? I can live with it losing all the values, or keeping all the values. But not keeping some and forgetting about others

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    It's easier if you just reset all the selections and default text values.

    <body onload="document.theForm.reset()">
    Glenn
    ____________________________________

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

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Yes, it is, but... I have a feeling that the people who are testing this particular site are going to be asking questions along the lines of "You can make it keep what I entered for those boxes, why can't you do it for these ones over here on the same page?" and all I'm going to be able to answer is "I don't know"

  • #4
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could use cookies to store the information they enter, then retrieve the cookie when the form page is opened?

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by Spudhead
    Yes, it is, but... I have a feeling that the people who are testing this particular site are going to be asking questions along the lines of "You can make it keep what I entered for those boxes, why can't you do it for these ones over here on the same page?" and all I'm going to be able to answer is "I don't know"
    I thought you can live with it losing all values?
    I can live with losing all the values
    Actually, I haven't duplicated what you experienced in IE6 and Firefox resetting some select values. I created a sample page and tested with those browsers and all the previous selections were retained. Probably your comboboxes are programmatically created by Javascript? If it is, then the only solution is to use cookies as mark87 suggested. When the page is submitted and being processed (I assume you're using a server-side language for this), you store the data in cookies. And onload of the form, set the default values of the fields based from the retrieved cookies.
    Glenn
    ____________________________________

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


  •  

    Posting Permissions

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