Galen,
This may be of little help, but might get you pointed in the right
direction...
The following code works in FF 1.5.0.7 (PC):
// dummy data
var routes=new Array();
routes[0]="Zero";
routes[1]="One";
routes[2]="Two";
var options="";
for(i = 0; i < routes.length; ++i) {
options += ' <option value="' + routes[i] + '">' + routes[i] +
'</option>\r\n';
}
options += "</select>";
$("#routeselect").html(options);
However, it bombs (empty <select>) in both IE6 and O9...
________
SEAN O
Galen Palmer wrote:
>
> Thanks for the reply and the link to the library.
>
> The interesting thing is that the default .append behavior seems to
> work for just about everything else (appending <li> to <ol> and
> <spans> to a <div>) it's just appending <option> to a <select> that I
> can't get to work.
>
> Galen
>
> On 10/10/06, patrickk <[EMAIL PROTECTED]> wrote:
>> 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/
>>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/Appending-%3Coption%3E-to-%3Cselect%3E-tf2419444.html#a6749350
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/