Un approccio.
codice HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
//Dichiaro l'array
var arr = new Array();
arr[0] = new Array(7,'Cane');
arr[1] = new Array(84,'Abete');
//Dichiaro l'array
var arr2 = new Array();
arr2[0] = new Array(1,'Uno');
arr2[1] = new Array(2,'Due');
arr2[2] = new Array(3,'Tre');
arr2[3] = new Array(4,'Quattro');
arr2[4] = new Array(5,'Cinque');
function popola_select(idDiv, idSelect, anArray){
var html = '<select name="'+idSelect+'" id="'+idSelect+'" >';
for (i=0;i<anArray.length;i++) {
option = '<option value="'+anArray[i][0]+'">'+anArray[i][1]+'</option>';
html = html+option
}
html = html+'</select>';
document.getElementById(idDiv).innerHTML = html;
}
</script
</head>
<body>
<form>
<div id="pippo"></div><br/>
<div id="pluto"></div><br/>
<input type="button" value="crea select 1" onclick="popola_select('pippo','sel01',arr)">
<input type="button" value="crea select 2" onclick="popola_select('pluto','sel02',arr2)">
</form>
</body>
</html>