On 25/01/2008, Justin Perkins <[EMAIL PROTECTED]> wrote:
>
> Take the advice of kangax and Richard,
>
> To set the selected item of a select box, you use selectedIndex.
>
> There is no better way. Setting the selected attribute on an option is
> not a reliable means of setting the selected state, not to mention it
> requires you to "unset" the selected attribute on another option.
>
> -justin
>

Just adding a few notes to this questio (not directly in response to
Justin's recommendation).

There are effectively 2 type of select boxes.

select-multiple and select-single

They behave slightly different with regard to the "select" properties.

If select-single is used, then $('select').selectedIndex is the property to use.

If select-multiple is used, then you $('option_x').selected is the
property to use.

With select-multiple, you can set multiple options (you got that,
right, from the name select-multiple, right? Yes? <grin>).

That is why there is a select property on the option.


Having read through the rest of the posts here, I think the multiple
select has been ignored and erroneous information about
option.selected has been presented.

Setting option.selected is perfectly fine if your select is <select
multiple><opti....></select>

Richard.

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to