The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Remembering Selection in Select List

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #30701

    I’m using this bit of code below for a Select List, as you can see I’ve got a bit of PHP between each option that remembers the selection when the page is reloaded.

    MY HTML:

    Unfortunately I need to scrap the code (above) and use the code below (JavaScript). The problem is I need the selection to be remembered, exactly as it is above. So when the page is reloaded the users selection on the list doesn’t go away/reset. How can I achieve this in the code below?


    if (BuyRent=='buy')
    document.SearchForm.MaxPrice.options[0]=new Option("Price (Max)","150000000");
    document.SearchForm.MaxPrice.options[1]=new Option("u00A3100,000","100000");
    document.SearchForm.MaxPrice.options[2]=new Option("u00A3200,000","200000");

    Thanks in advance.


    use cookies.

    you could use setcookie() function in php. when the user has made the selection set the cookie using that function, then when the page is reloaded/redirected, just read the cookie values and apply it.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.