...

View Full Version : Getting multiple values from List Box



eshban
09-07-2005, 08:23 AM
Hi,

I have a one LIST BOX , in which a user has option to select multiple values. I want that if user select 3 values from LIST BOX, then my program print all these three values on the submission of the form

plz help me in in the code

bye

missing-score
09-07-2005, 11:16 AM
example:



<form action="file.php" method="post">
<select name="myselect[]" id="myselect" multiple="multiple">
<option value="option_1">Option 1</option>
<option value="option_2">Option 2</option>
<option value="option_3">Option 3</option>
<option value="option_4">Option 4</option>
</select>
<input type="submit" value="Submit" />
</form>


and the PHP:



<?php

$all_selected_values = '';
foreach($_POST['myselect'] as $value)
{
$all_selected_values .= $value."\r\n";
}

?>


Does that help? :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum