PDA

View Full Version : innerHtml IE7



krishnapal
11-27-2008, 09:51 AM
Hello all,

I have recently made an application in which I am using "innerHtml" to fill "option" of dropdown
document.getElementById('list').innerHTML=arr[0];
here "list" is the id of the <select>,

It is working fine on all browsers except IE7,

Please help me in this problem .

i know innerHtml don't work on IE7 , but what is the alternative to do this task ,
please help me

jscheuer1
11-27-2008, 04:06 PM
See:

http://www.mredkj.com/tutorials/tutorial005.html

or you could use DOM level 2 methods (just something I threw together):


function popsel(){
var oMake = function(v, t){
var o = document.createElement('option');
o.value = v;
o.appendChild(document.createTextNode(t));
document.getElementById('list').appendChild(o);
}, l = ['one', 'two', 'three'];
for(var i = 0; i < l.length; ++i)
oMake(i + 1, l[i]);
}


<input type="button" onclick="popsel();"><br>
<select id="list">

</select>