September 20th, 2005, 08:19 AM
Join Date: Feb 2003
Location: Yerevan, Armenia
Time spent in forums: 21 h 1 m 30 sec
Reputation Power: 11
<select> innerHTML problem
Ok, what I'm trying to do is use the innetHTML property of a <secelct> box to change it's contents. What I do is generate a string with a list of <option> tags and then use
document.getElementById("mybox").innerHTML = s;
to fill the select box.
Now it doesn't work, particularily, the contents of the select box are displayed in a single string. When it should have been 3 items like
it's really one item showing in the drop down menu:
Now I looked at the contents of the string before putting it into the innerHTML and at the innerHTML after assigning the string to it. It looks pretty wierd. The string at first seems right
<option value=1>item1</option><option value=2>item2</option>
but after inserting the innerHTML contains something like
lacking the first opening option tag.
Does anyone have an idea as to what's the problem here and how it can be fixed?
You'll live, only the best get killed.