Forum Moderators: coopster
<select name="state" size="5" multiple="MULTIPLE" id="state">
<?php
do {
?>
<option value="<?php echo $row_Recordset2['state']?>"><?php echo $row_Recordset2['state']?></option>
<?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
$rows = mysql_num_rows($Recordset2);
if($rows > 0) {
mysql_data_seek($Recordset2, 0);
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
}
?>
</select>
but need to pass multiple select values to hidden field:
<input type="hidden" name="hiddenField" value="<?php print $state?>" />
Upon selecting multiple values I get them returned in the URL:
http://www.example.com/test2.php?state=Alaska&state=Alabama
but only the last chosen state is returned in the hidden field such as Alabama in the above example.
[edited by: eelixduppy at 10:16 pm (utc) on Dec. 17, 2007]
[edit reason] delinked [/edit]
To move them along into a hidden field I think you'll need to string them together with a delimiting character. In general this would be a character that would never be a part of the data, which in this case could be anything that's not part of the alphabet. In the section of the script that receives the selection, do:
$states = implode [php.net](',',$_GET['state']);
then
<input name="selectedstates" type="hidden" value="<?php echo $states;?>">
In the script that processes that form (assuming method="get" again):
$state = explode(',',$_GET['selectedstates']);
to get them back into an array.