![]() Topic awaiting preservation: php form select option question (Page 1 of 1) |
|
---|---|
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
![]() Hi all, |
Paranoid (IV) Inmate From: f(x) |
![]() Something like this: code: <?php $statelist = array('AL', ... the others ... ,'WY'); ?> ... <select name="state"> <? foreach ($statelist AS $key=>$val){ if ($_GET['state'] == $val){ echo "<option value=\"$val\" selected=\"selected\">$val</option>\n"; }else{ echo "<option value=\"$val\">$val</option>\n"; } } ?> </select>
|
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
![]() thank you zavaboy |
Maniac (V) Mad Scientist with Finglongers From: Germany |
![]() code: if ($_GET['state'] == $val){
code: if (isset($_GET['state'] && $_GET['state'] == $val){
|
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
![]() thanks for the extra bit there TB although I changed it slightly... ;-) code: if (isset($_GET['currentstate']) && $_GET['currentstate'] == $val){ |
Maniac (V) Mad Scientist with Finglongers From: Germany |
![]() yes.... don't let me type code after long working weekends |