"Alex Hogan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> > Use HTML attribute "selected" in the option field you want to
> > set as default...
>
> Yes.., thank you.., however I am more interested in how to force that
selection to a specific option tag in the dropdown from a search. If I'm
missing your point please excuse me. I'm a little brain dead this morning.
>
> If I have something like this what I'll want to do is to identify the
point in the array where I can force the selected to be the default based on
the previous search.
>
> <select name="sellocation" class="body_text" id="sellocation">
> <option value="0" <?=$option[0]?>>Make Selection</option>
> <?
> $i = 1;
> while($row = mssql_fetch_array($result))
> {
> $v = $row['loc_id'];
> $n = $row['loc_city'];
> echo "<option value=\"$v\" $option[$i]>$n</option>";
> }
Try this:
while ($row = mssql_fetch_array($result)) {
$v = $row['loc_id'];
$n = $row['loc_city'];
echo "<option value=\"$v\" ";
// if current loc_id is previously selected loc_id set selected
echo ($_POST['sellocation'] == $v) ? 'selected' : '';
echo "$option[$i]>$n</option>";
}
Regards,
Torsten Roehr
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php