| re: Setting "text" value to "option" element in IE
gabon wrote:[color=blue]
> I'm creating a select entirely through JavaScript and very strangely IE
> doesn't show the text in the option elements.
>
> Here part of the code:
>
> this.form_country=document.createElement("select") ;[/color]
I'll use this for convenience, you may chose to do so, or not:
var sel = document.createElement("select");
[color=blue]
> var option;
> for(var i=0; i<arr.length; i++){[/color]
Replace from here...
[color=blue]
> option=document.createElement("option");
> option.value=arr[i].code;
> option.text=arr[i]._value;
> alert(option.value+" - "+option.text);
> this.form_country.appendChild(option);[/color]
.... to here with:
sel.options[sel.options.length] =
new Option(arr[i]._value, arr[i].code);
Change 'sel' back to 'this.form_country' if you want.
[color=blue]
> }
>
> It works perfeclty on FireFox, funny thing is that the alert works
> properly but there is no way to see any text inside :S
>
> Any idea? Of course I googled and very strangely I didn't find anything
> about it.[/color]
Syntax of new Option is:
new Option([text[, value[, defaultSelected[, selected]]]])
where defaultSelected & selected are booleans (true/false).
This is an old reference, but all I could find in a hurry (sleep
beckons...):
<URL:http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/reference/option.html>
--
Rob |