将js里的一个数组里面的值动态地添加到一个下拉框中

subcat[66] = new Array( "苏适 ", "书法欣赏 ", "苏适 "); 

subcat[67] = new Array( "刘艺 ", "书法欣赏 ", "刘艺 "); 

subcat[68] = new Array( "爱新觉罗·启骧 ", "书法欣赏 ", "爱新觉罗·启骧 "); 

subcat[69] = new Array( "苗培红 ", "书法欣赏 ", "苗培红 "); 

onecount=70; 

function changelocation(locationid) 
document.myform.SmallClassName.length = 1; 
var locationid=locationid; 
var i; 
for (i=0;i < onecount; i++) 
if (subcat[i][1] == locationid) 
document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]); 


向select添加option有两种常用方法 
(1) selectid.options[i] = new Option(text,value); 
(2) selected.options.add(new Option(t,v));

你可能感兴趣的:(js)