Name is not a valid attribute of the option element so, I have used id instead. In other words, the created options will have the id of option0, option1, option2 - rather than name.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
onload=function(){
var array1 =
["[Select Number]",
"One",
"Two"]
for (var i_tem = 0; i_tem < array1.length; i_tem++){
array1[i_tem]=[array1[i_tem], document.createElement('option')]
array1[i_tem][1].id='option'+i_tem
array1[i_tem][1].appendChild(document.createTextNode(array1[i_tem][0]))
document.getElementById('toFill').appendChild(array1[i_tem][1])
}
}
</script>
</head>
<body>
<select id="toFill" name="s1" onchange="alert(this.options[this.selectedIndex].id)">
</select>
</body>
</html>
The onchange event for the select is just a test to see if the id attributes were correctly assigned.
Bookmarks