2 回答
![?](http://img1.sycdn.imooc.com/54584d6100015f5802200220-100-100.jpg)
TA贡献1803条经验 获得超3个赞
![?](http://img1.sycdn.imooc.com/54584f850001c0bc02200220-100-100.jpg)
TA贡献1799条经验 获得超9个赞
这个是select选择控件里的选项吧
new可以为select控件动态添加选项的
给你一个例子吧,有不懂的再问吧
//设置店铺等级
function SetCategroy()
{
//如果品牌不为空
if(document.form1.DropListBrand)
{
//如果品牌选择的是特惠店
if(document.form1.DropListBrand.options[document.form1.DropListBrand.selectedIndex].value == "Discount")
{
//将原来的店铺等级数据清空
document.form1.DropListCategory.options.length = 0;
//添加等级为 *,代表特惠店
document.form1.DropListCategory.options[0] = new Option("*","*");
document.form1.DropListCategory.options[0].selected = true;
}
//如果不是特惠店
else
{
//如果店铺等级对象不为空
if(category)
{
var i = 0;
document.form1.DropListCategory.options.length = 0;
//将店铺等级对象中的数据添加到等级下拉控件中,为A,B,C,D,E
for(var str in category)
{
document.form1.DropListCategory.options[i] = new Option(str,str);
i++;
}
}
}
}
}
添加回答
举报