Grow your CSS skills. Land your dream job.

Remembering Selection in Select List

  • # November 15, 2010 at 11:12 pm

    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?

    MY JAVASCRIPT:

    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.

    # November 19, 2010 at 6:04 am

    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)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".