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.
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.