Get value of select field on load

Posted on 2012-09-08
Last Modified: 2012-09-08

I have a select field and I want it so that when people go back it loads the previous selection. By default the browser posts the select field but I want it to echo the value.

<select name="make">
<option value="Make 1">Make 1</option>
<option value="Make 2">Make 2</option>

If option 1 was selected and the form was submitted then when someone pushes the back button I want it to echo the value of the option 1.

Hope that makes sense.

Question by:movieprodw
    LVL 31

    Accepted Solution

    2 options are

    (1) Remember the selection using cookies

    (2) Submit the form information using Ajax so that you don't move from the page after submission.

    This is not a trivial problem.
    LVL 1

    Author Closing Comment

    Used sessions, thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
    In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now