2 回答

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊
這個(gè)是select選擇控件里的選項(xiàng)吧
new可以為select控件動(dòng)態(tài)添加選項(xiàng)的
給你一個(gè)例子吧,有不懂的再問(wèn)吧
//設(shè)置店鋪等級(jí)
function SetCategroy()
{
//如果品牌不為空
if(document.form1.DropListBrand)
{
//如果品牌選擇的是特惠店
if(document.form1.DropListBrand.options[document.form1.DropListBrand.selectedIndex].value == "Discount")
{
//將原來(lái)的店鋪等級(jí)數(shù)據(jù)清空
document.form1.DropListCategory.options.length = 0;
//添加等級(jí)為 *,代表特惠店
document.form1.DropListCategory.options[0] = new Option("*","*");
document.form1.DropListCategory.options[0].selected = true;
}
//如果不是特惠店
else
{
//如果店鋪等級(jí)對(duì)象不為空
if(category)
{
var i = 0;
document.form1.DropListCategory.options.length = 0;
//將店鋪等級(jí)對(duì)象中的數(shù)據(jù)添加到等級(jí)下拉控件中,為A,B,C,D,E
for(var str in category)
{
document.form1.DropListCategory.options[i] = new Option(str,str);
i++;
}
}
}
}
}
添加回答
舉報(bào)