I have the script below in which a multiple select box is populated from a db. When options are selected the form is resubmitted as there are several other user imputs that need to be carried out.
I need to ensure that when the form gets resubmitted the options selected in the multiple select box get the selected tag appended to them to ensure if the user resubmits the form based upon another select box the previously chosed options remain selected.
The script below works only if you click the submit button twice.
Can anyone tell me how to get the "stristr" variable to check the string when the submit button is pressed first time. It only seems to work on the second click.
<td width="79" colspan="3"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<select name="selectoffers[]" size=1 multiple alt"select">
<option value="<?php echo $deductions["custoffer1"] ?>" <?php if (stristr($custoffers,$deductions['custoffer1'])) { echo 'selected'; } ?>><?php echo $deductions["custoffer1"] ?>
<option value="<?php echo $deductions["custoffer2"] ?>" <?php if (stristr($custoffers,$deductions['custoffer2'])) { echo 'selected'; } ?>><?php echo $deductions["custoffer2"] ?>
<option value="<?php echo $deductions["custoffer3"] ?>" <?php if (stristr($custoffers,$deductions['custoffer3'])) { echo 'selected'; } ?>><?php echo $deductions["custoffer3"] ?>
<option value="<?php echo $deductions["custoffer4"] ?>" <?php if (stristr($custoffers,$deductions['custoffer4'])) { echo 'selected'; } ?>><?php echo $deductions["custoffer4"] ?>
<option value="<?php echo $deductions["custoffer5"] ?>" <?php if (stristr($custoffers,$deductions['custoffer5'])) { echo 'selected'; } ?>><?php echo $deductions["custoffer5"] ?>
</select>
</font></td>
</tr>
<tr>
<td colspan="4"><center>
<input type="text" name="custoffers" size="54" value="<?php
if (is_array($selectoffers))
{
while(list($key, $value) = each($selectoffers))
{
echo $value . ", ";
}
}
?>"></center>
</td>