inspiration_ryan inspiration_ryan - 1 year ago 70
PHP Question

Pre populate select based on submitted value from the same select

I have a select box which when selected reloads the page, how can I make sure the select still holds the selected value after the page reloads?


Answer Source

Actually thier is no way for catch the selected value after reloads the page. You can do it :

  1. By Post
  2. By Get
  3. By Session
  4. By cookie
  5. Or BY ajax (Not reload the page)

You can selected option by this way value test . e.g.

if(isset($_POST['select']) && $_POST['select']==2){ echo "<option value='2' selected>Second</option>"; }  

Same thing you can do with other PHP GLobal variables.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download