With most any browser nowadays, on a non-multiple select the first
option will be selected unless you specifically setup a default.  With
a multiple select, it will not default to anything and will not even
post/get a variable for it at all unless the user specifically selects
something, which is why a isset($var) will work for a multiple.


On Mon, 18 Oct 2004 07:59:47 -0700, bruce <[EMAIL PROTECTED]> wrote:
> john...
> 
> the code (and the rfc) seems to suggest otherwise. personally, i would have
> thought, if the user doesn't select a menu, then the 'menu item' should not
> have anything with regards to the querystring...
> 
> however, the spec implies something different:
> http://www.w3.org/TR/REC-html40/interact/forms.html#edef-OPTION
> 
> --------------------
> 17.6.1 Pre-selected options
> Zero or more choices may be pre-selected for the user. User agents should
> determine which choices are pre-selected as follows:
> 
> If no OPTION element has the selected attribute set, user agent behavior for
> choosing which option is initially selected is undefined. Note. Since
> existing implementations handle this case differently, the current
> specification differs from RFC 1866 ([RFC1866] section 8.1.3), which states:
> The initial state has the first option selected, unless a SELECTED attribute
> is present on any of the <OPTION> elements.
> Since user agent behavior differs, authors should ensure that each menu
> includes a default pre-selected OPTION.
> ---------------------
> 
> if you can manage to create a sample that has 2 menu lists, each with a few
> items that has the behavior you say should occur, i'd like to take a look.
> 
> i currently have code which lists 3 menus, each of which has a few items in
> the list...
> 
> all the menu/lists are within a single form, with a single "inputBTN".
> 
> if the user selects the menu/list for states that has a multiple select,
> then the other two lists return their 1st items, even though they haven't
> been selected....
> 
> 
> 
> thanks
> 
> -bruce
> 
> -----Original Message-----
> From: John Nichel [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 18, 2004 7:31 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] how to create multiple selects within php
> 
> 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
> [EMAIL PROTECTED]
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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

Reply via email to