js里面定义一个数组 怎样把数组里面的值动态的添加到一个下拉框中?
var lists =new Array( "值一 ", "值二 ");
我这里有一个下拉框。怎样把值一,值二动态添加到下拉框中?
------解决方案--------------------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));