Skip to content Skip to sidebar Skip to footer

How To Set The InnerHTML Of HTML Drop Down List In IE

I have one html drop down list and button. when i clic

Solution 1:

Your code worked on my IE11, but not on my IE8.

This worked on my IE8:

<script type="text/javascript">
function abc()
{
    document.getElementById('ddl').innerHTML = ''; // clear <select> contents
    var a = document.createElement('option');      // create an <option> elem
    a.setAttribute('value', 'TN_Pulling');         // set 'value' attr val
    a.setAttribute('selected', 'selected');        // set 'selected' attr val
    a.innerHTML = 'TN_Pulling';                    // set <option> contents
    document.getElementById('ddl').appendChild(a); // append <option> to <select>
}
</script>
<select style="width:170px" id="ddl"></select>
<input type="button" value="getvalue" onclick="abc()" />

Good Luck.


Post a Comment for "How To Set The InnerHTML Of HTML Drop Down List In IE"