Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mark Selected on Dropdown based on Variable
- You could pull info from a GET/POST or MySQl query
- <?
- //I prefer to assign to a variable and then compare
- $EyeColor = $_GET['EyeColor'];
- //for testing - comment out when not needed
- echo $EyeColor;
- ?>
- <select name="EyeColor">
- <option value=""<?=$EyeColor == '' ? ' selected="selected"' : '';?>> </option>
- <option value="blue"<?=$EyeColor == 'blue' ? ' selected="selected"' : '';?>>Blue</option>
- <option value="brown"<?=$EyeColor == 'brown' ? ' selected="selected"' : '';?>>Brown</option>
- </select>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement