On Jan 26, 9:26 am, "Justin Perkins" <[EMAIL PROTECTED]> wrote:
> Take the advice of kangax and Richard,
>
> To set the selected item of a select box, you use selectedIndex.
That is one option.
> There is no better way.
Depends on your criteria for "better".
> 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.
No, it doesn't.
For a single-select element, using script to set an option's selected
attribute to true (i.e. setting the DOM element's selected property)
makes it the currently selected option.
<URL: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-70874476 >
However, using innerHTML to add a second option element with an HTML
selected attribute will cause the document to have invalid markup.
How the browser translates that into a DOM is likely browser dependent
as it relies on error correction.
--
Rob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---