This seems to work fine in MSIE, and hopefully no side effects, if you find something wrong, please let me know, thanks.
<html>
<body>
<select id="si">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<script type="text/javascript">
var e=document.getElementById("si");
e.size=3;
var a = new Array();
var n = new Array();
var x = 2;
if(!a.length)for(var i=0,m=e.length;i<m;i++) {
a.push(e[i].value);
}
while(e.firstChild)
e.removeChild(e.firstChild);
for(var i=0,m=a.length;i<m;i++) {
if(x==a[i]) {
e.add(new Option(a[i],a[i]));
}
}
</script>
</body>
</html>
source
share