<SELECT> tag

liunx

Guest
this is what I have:<br />
<br />
<FORM Action="test.php" MULTIPLE><br />
<SELECT Name="fruits" size="3"><br />
<OPTION value="1">Apple</OPTION><br />
<OPTION value="2">Orange</OPTION><br />
<OPTION value="3">Pineapple</OPTION><br />
<OPTION value="4">Grape</OPTION><br />
</SELECT><br />
</FORM><br />
<br />
my problem is, when I submit the form, I only get the value of the last selected item (despite the fact that the user can select multiple options frmo the list).<br />
<br />
$_POST["fruits"] = (the last of the selected options)<br />
<br />
I need to get the values of all of the selected options. How?<!--content-->I had to play around with this in one of my classes. I believe this is the code we used in HTML:<br />
<br />
<FORM Action="test.php"><br />
<SELECT Name="fruits[]" size="3" multiple><br />
<OPTION value="1">Apple</OPTION><br />
<OPTION value="2">Orange</OPTION><br />
<OPTION value="3">Pineapple</OPTION><br />
<OPTION value="4">Grape</OPTION><br />
</SELECT><br />
</FORM><br />
<br />
Adding the "[]" to the end of the SELECT name causes PHP to interpret the values sent from that SELECT as an array:<br />
<br />
$fruitArray = $_POST["fruits[]"];<br />
<br />
You'll want to post this in the PHP forum to just to make sure.<!--content-->
 
Back
Top