日期:2014-05-16  浏览次数:20337 次

下拉列表 关联显示的时候出问题啦~~ 在线等
两个关联的下拉列表,case "0 "时显示没问题。
可是case "1 "时,多了 "蓝草莓 "   ,   "红樱桃 "两个选项。   这是怎么回事啊?

function   chg_class()   {
var   form   =   document.forms[0];
switch   (form.select_3.value)   {
case   "0 ":

form.select_4.options[0].value= "甜蜜橙 ";
form.select_4.options[1].value= "黄香蕉 ";
form.select_4.options[2].value= "蓝草莓 ";
form.select_4.options[3].value= "红樱桃 ";
form.select_4.options[0].text= "甜蜜橙 ";
form.select_4.options[1].text= "黄香蕉 ";
form.select_4.options[2].text= "蓝草莓 ";
form.select_4.options[3].text= "红樱桃 ";

break;
case   "1 ":

form.select_4.options[0].value= "红发晶 ";
form.select_4.options[1].value= "虎眼石 ";
form.select_4.options[0].text= "红发晶 ";
form.select_4.options[1].text= "虎眼石 ";

break;
case   " ":

form.select_4.options[0].value= "甜蜜橙 ";
form.select_4.options[1].value= "黄香蕉 ";
form.select_4.options[2].value= "蓝草莓 ";
form.select_4.options[3].value= "红樱桃 ";
form.select_4.options[0].text= "甜蜜橙 ";
form.select_4.options[1].text= "黄香蕉 ";
form.select_4.options[2].text= "蓝草莓 ";
form.select_4.options[3].text= "红樱桃 ";

}
}

------解决方案--------------------
因为在case "1 "中没有对options 2 3 的处理,因此保持了前面的赋值,这样静态处理比较麻烦
------解决方案--------------------
case 1 时把options[2],options[3]置空!!!!!!!!!!!!!!!!!
------解决方案--------------------
在case 1 把options2,3置空,建议把数据存到数组里来操作