"TG" <tg********@cox.net> wrote in message news:<Pu5Nb.3235$Mb7.2047@lakeread04>...
Group,
I have several drop down boxes that I'd like to repopulate with the value
the user selected -- after the form posts by calling itself -- these fields
are blanked out. I am having difficulty getting the drop downs to repopulate
with the values the user's selected. If any of you have implemented this
before, how have you done this and what is the syntax?
Thanks,
Use a select box like following:
[HTML]
<select name="mySelect">
<option value="1" <?=$mySelectOption['1']?>>option1</option>
<option value="2" <?=$mySelectOption['2']?>>option2</option>
<option value="3" <?=$mySelectOption['3']?>>option3</option>
<option value="4" <?=$mySelectOption['4']?>>option4</option>
<option value="5" <?=$mySelectOption['5']?>>option5</option>
<option value="6" <?=$mySelectOption['6']?>>option6</option>
</select>
[/HTML]
And code your PHP like following:
[PHP]
$mySelectOption['1'] =
$mySelectOption['2'] =
$mySelectOption['3'] =
$mySelectOption['4'] =
$mySelectOption['5'] =
$mySelectOption['6'] = '';
if(!empty($_REQUEST['mySelect']))
$mySelectOption[$_REQUEST['mySelect']] = 'selected';
else
$mySelectOption[1] = 'selected'; // Default selected, for first time
[/PHP]
This is just a possible way to achieve this.
Another method will be output your Select box in a loop and check for
selected condition, and ouput the *selected* text when necessary.
--
Cheers,
Rahul