Pre-Select HTML Select Form


/ Published in: PHP
Save to your folder(s)

Pre-selects an html form with a requested value... ie; editing a form from a database


Copy this code and paste it in your HTML
  1. //applicable values
  2. $values = array('value1', 'value2', 'value3', 'value4', 'value5');
  3. //get current value
  4. $val = $_REQUEST['value'];
  5. //print html selection
  6. echo "<select>";
  7. foreach($values as $v) {
  8. $s = ($val == $v) ? " selected='selected'" : null;
  9. echo "<option$s>$v</option>\n",
  10. }
  11. echo "</select>";

URL: http://davidsword.ca/?library

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.