Page 1 of 1

null input from multiple selection list

Posted: Fri Oct 27, 2006 10:06 am
by sh33p1985
theres an element to my php form that allows the user to make multiple selections from a list. i know how to handle multiple selections when the form is submitted, but how do i capture and handle the scenario if no selections are made (i.e. the user should select at least 1 option from the list).

Thanks

Posted: Fri Oct 27, 2006 11:25 am
by feyd
Typically, the field will not appear in the submission data, or will only appear with the default selection depending on how you've written the field.

Posted: Fri Oct 27, 2006 11:30 am
by sh33p1985
default is nothing selected, so when the script is invoked via the submit button

Code: Select all

$availableSizes = $_POST['availableSizes'];
will throw an error no?

i want to catch that and throw it back to the form and inform the user than they did not make any selection.

Posted: Fri Oct 27, 2006 12:26 pm
by volka

Code: Select all

if ( !isset($_POST['availableSizes']) ) {
...
}