I´m using the plugin for "DOM creation" to accomplish that.
see
http://mg.to/2006/02/27/easy-dom-creation-for-jquery-and-prototype
patrick
Am 10.10.2006 um 22:49 schrieb Galen Palmer:
> Hi All,
>
> I'm new to jquery but like what I see so far.
>
> I have an array of strings that I'd like to add to a <select> element
> as <option> elements.
>
> HTML:
>
> <select id="routeSelect">
> </select>
>
> JavaScript:
>
> for(var i = 0; i < routes.length; ++i) {
> $("#routeSelect").append("<option value=\""
> + routes[i] +"\">"+ routes[i] +"</option>");
> }
>
> The above code appears to just append the text to the select element
> without creating the child option elements. Viewing the generated
> source (in Web Developer in Firefox) shows htm like: <select
> id="routeSelect">abcdef</select>
>
> However, the following code (more "old school") seems to work fine.
>
> var routeSelect = $("#routeSelect").get(0);
> for(var i = 0; i < routes.length; ++i) {
>
> routeSelect.options[i + 1] = new Option(
> routes[i],
> routes[i]);
> }
>
> I'm using firefox under Mac OSX though it looks like the same behavior
> under safari and opera.
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/