RETAINING THE VALUE OF A PULL DOWN LIST AFTER A FORM IS RE- SENT - Dec 27th, 2022


Here's what I've used for a single value list field:

<select name="venue_parking" >
<option value"" <?php if($_REQUEST['venue_parking'] == ""){echo "selected=\"selected\"";} ?> >Select </option>
<option value"Street" <?php if($_REQUEST['venue_parking'] == "Street"){echo "selected=\"selected\"";} ?>
>Street</option>
<option value"On Site Free" <?php if($_REQUEST['venue_parking'] == "On Site Free"){echo "selected=\"selected\"";} ?> >On
Site Free</option>
<option value"On Site Paid" <?php if($_REQUEST['venue_parking'] == "On Site Paid"){echo "selected=\"selected\"";} ?> >On
Site Paid</option>
</select>

And here's what was suggested for a multi value list field (never tested):

<select name="foo[]" multiple="multiple" size="3">
<option value="" <?php if(isset($_POST['foo'])) { foreach($_REQUEST['foo'] as $tmp) { if($tmp == "") { echo
"selected=\"selected\""; break; }}}?>>Please Select One Or More Values</option>
<option value="bar" <?php if(isset($_POST['foo'])) { foreach($_REQUEST['foo'] as $tmp) { if($tmp == "bar") { echo
"selected=\"selected\""; break; }}}?>>bar</option>
<option value="hello" <?php if(isset($_POST['foo'])) { foreach($_REQUEST['foo'] as $tmp) { if($tmp == "hello") {
echo
"selected=\"selected\""; break; }}}?>>hello</option>
<option value="world" <?php if(isset($_POST['foo'])) { foreach$_REQUEST['foo'] as $tmp) { if($tmp == "world") {
echo
"selected=\"selected\""; break; }}}?>>world</option>
</select>



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service