PDA

View Full Version : Replace options in a select



tuga
11-06-2008, 04:33 PM
Hi there,

I'm trying to replace the options in a select but without luck, it works fine on FF but not on IE.
I think this is a very basic question but i cannot figure it out. I'm trying to use the innerHTML as I'm using AJAX to retrieve a response and the response is something like "<option value="modelA">Model A</option>", i even tried with following code but doesn't seems to work on IE, it just empties the select.



<select name="lbModel" class="big" id="lbModel">
<option value="0">Model</option>
</select>
<a href="javascript:replaceOptions()">Replace</a>




//javascript

function replaceOptions(){
var obj = document.getElementById("lbModel");
obj.innerHTML = '<option value="modelA">Model A</option>';
}


Please can anyone help this newbie.

tuga
11-06-2008, 05:44 PM
i've been tryinh to understand this and in IE it actually writes.

Here is the innerHTML in IE

Model A</OPTION>
its missing the initial <option>

Why?


Thanks

tuga
11-06-2008, 07:46 PM
http://support.microsoft.com/kb/276228