Topic awaiting preservation: php form select option question |
|
---|---|
Author | Thread |
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
posted 07-01-2007 19:04
Hi all, |
Paranoid (IV) Inmate From: f(x) |
posted 07-01-2007 19:21
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.... |
posted 07-01-2007 19:28
thank you zavaboy |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 07-01-2007 20:27
code: if ($_GET['state'] == $val){
code: if (isset($_GET['state'] && $_GET['state'] == $val){
|
Maniac (V) Mad Scientist From: Jacks raging bile duct.... |
posted 07-01-2007 22:19
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 |
posted 07-01-2007 23:46
yes.... don't let me type code after long working weekends |