-
I have a select form field that allows you to choose multiple options (as used with the SET data type in mySQL). Here is my form:
Code:
Format(s): <select name="format_type" size="3" multiple>
<option value="Compact Disc">Compact Disc
<option value="Cassette">Cassette
<option value="Vinyl">Vinyl</select>
When I submit the form, $format_type will only hold the value of the last item selected. For example, if I select all 3, $format_type will hold "Vinyl" only.
What am I doing wrong here? Is the form correct?
-
you need to make the name of the select an array so fo your code:
<select name="format_type[]" size="3" multiple>
<option value="Compact Disc">Compact Disc
<option value="Cassette">Cassette
<option value="Vinyl">Vinyl</select>
No the script that processes this can access it as:
print "Your selections: <br>";
foreach($format_type as $type) {
print $type."<br>";
}
-