2 回答

TA貢獻1824條經驗 獲得超8個贊
這個是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++;
}
}
}
}
}
添加回答
舉報