我这里有一个下拉框。怎样把值一,值二动态添加到下拉框中?
2 个解决方案
#1
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]);
}
}
}
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]);
}
}
}
#2
向select添加option有两种常用方法
1 selectid.options[i] = new Option(text,value);
2 selected.options.add(new Option(t,v));
1 selectid.options[i] = new Option(text,value);
2 selected.options.add(new Option(t,v));
#1
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]);
}
}
}
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]);
}
}
}
#2
向select添加option有两种常用方法
1 selectid.options[i] = new Option(text,value);
2 selected.options.add(new Option(t,v));
1 selectid.options[i] = new Option(text,value);
2 selected.options.add(new Option(t,v));