|
Posted by Geoff Berrow on 06/19/06 23:59
Message-ID: <1150760275.219250.264370@u72g2000cwu.googlegroups.com> from
dshan@web.de contained the following:
>The PHP script returns, e.g., an "AL" string for Alabama. Of course, I
>don't want to write PHP code for each option to make it selected.
The way I do it requires some setup, but you only do it once,
First you create an array of states and codes
e.g.
$states= array("AL"=>"Alabama","TX"=>"Texas","VA", "Virginia",...);
then use PHP to create your select box
Untested.
<select name='state'>
<?php
foreach($states as $key=>$value){
if(isset($_POST[$key]) &&$_POST[$key]==$value){
$selected="selected";
}
else{
$selected="";
}
echo"<option value='$key' $selected >$value</option>\n";
}
?>
</select>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Navigation:
[Reply to this message]
|