Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 28th, 2012  |  syntax: None  |  size: 0.39 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Dynamic default selection for a drop down menu using url variables
  2. if (isset($_GET['id']))
  3.         $id = ($_GET['id']);
  4.  
  5.     if ($id = 4)
  6.         $id4 = true;
  7.     else
  8.         $id4 = false;
  9.  
  10.     ...
  11.  
  12.     <option value="Value" selected="<?php echo "$id4"; ?>">
  13.         Value
  14.      </option>
  15.        
  16. <option<?php if (isset($_GET['id']) && $_GET['id'] == 4){ echo ' selected'; } ?>>
  17.     value
  18. </option>