This form shows how to create combo, single select list boxes, and multiple select boxes. The form is submitted to a PHP page that handles the form data passed to it. How that data is handled is also discussed below.
Combo Box / Drop-down List
First the combo or drop down box is shown. This form of box includes multiple choices, but only 1 may be selected. In addition, only one option is shown in the list box itself. The for the box looks like this:
Combo Box
The select tag identifies the name of the list box, and each option tag identifies both the value that is passed with the form, and the text that appears in the combo box.
List Box - Single Select
List Box - Single Select
This form is processed by the listbox.php script. You can see the code for this script as follows:
ListBox.php
1:<html> 2:<head> 3:<title>List Box Form Data</title> 4:</head> 5:<body> 6:<h3>List Box Form Data</h3> 7:<p>Form data passed from the form</p> 8: 9: echo "<p>select: " . $_POST['select']."</p>\n"; 10: echo "<p>listbox: " . $_POST['listbox'] . "</p>\n"; 11: $values = $_POST['listmultiple']; 12: echo "<p>listmultiple: "; 13: foreach ($values as $a){ 14: echo $a; 15: } 16: echo "</p>\n"; 17: ?> 18:</body> 19:</html> 20: