Re: how to create multiple selects within php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



bruce wrote:
ok...

it appears to be a case of user err.. the spec seems to state that if the
user doesn't select/specify an item, the select should return the 1st item
within the list... arrrgggh!! this is what's happening...

Not true. If the user doesn't select anything, nothing will be submitted (unless you have one or more of your option tags like this <option value="bar" selected />)


so my question is still, how can i implement some logic that requires the
user to actually select an item? or, how can i detect when a user has
actually selected a list item??????

Test to see if anything has been submitted. If your select tag is as such...


<select name="foo[]" multiple>

When you submit the form, you can check it like this...

if ( isset ( $_POST['foo'] ) ) {
	//user has selected something
	do stuff
} else {
	//user did not select anything
	do other stuff
}

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@xxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux