Click to See Complete Forum and Search --> : select.option.innerHTML?


angrytuna
05-16-2003, 12:52 PM
I've written a function that finds a particular SELECT form element in form "myform":


s = document.myform.elements[0]
//<Object SELECT>

grabs its list of options, changes the length

s.options.length = (some number)

iterates through the list, and assignes values to the innerHTML of that particular option.


for(i=0;i<s.options.length;i++){
s.options[i].innerHTML = "some text";
}


This works like a champ on everything except IE for OSX. This will COMPLETELY and INDEFINITELY hang the browser, forcing you to kill the running browser process.

Does anyone have an idea as to why this is? Can anyone think of another way to change the size and visible text of a select list with javascript?

Thanks in advance.

~AT

khalidali63
05-16-2003, 01:01 PM
I think you should be using
s.options[i].text= "some text";

that is more appropriate...and am positive it will work for all browsers.

angrytuna
05-16-2003, 01:03 PM
That worked much better, thank you. :D

~AT

khalidali63
05-16-2003, 01:07 PM
:D
you are welcome