Getting results from a select multiple HTML tag.

The select multiple tag in an HTML construct allows users to select multiple items from a list. These items are then passed to the action c for the form. The problem is that they are all passed with the same widget name. I.e.
<select name=”var” multiple=”yes”>
Each selected option will arrive at the action handler as var=option1, var=option2, var=option3. Each option will overwrite the contents of the previous $var variable. The solution is to use PHP’s “array from form element” feature. The following should be used:
<select name=”var[]” multiple=”yes”>
Now first item becomes $var[0], the next $var[1], etc.

Tags: , , , , , , , , , ,

Leave a Reply