这个temp取得的是opt_city中被选中的项的value值 for (m=temp.options.length-1;m>0;m--) //这个for循环将opt_city中的内容清空 for (i=0;i<group[x].length;i++){ //这个for循环将opt_city中的内容更新成北京、东京、汉城 html表单属性,查看html教程,百度上去搜,有一大堆
var temp=document.doublecombo.opt_city; //这个temp取得的是选择框对象的引用,用以简化代码 function redirect(x){ for (m=temp.options.length-1;m>0;m--) //这个for循环是为了清空这个opt_city下拉框组,其实整个for可以用temp.length = 0;来代替,更快 temp.options[m]=null; for (i=0;i<group[x].length;i++){ //这个for是添加新的OPTION组进去,最后选中第一个. temp.options[i]=new Option(group[x][i].text,group[x][i].value);} temp.options[0].selected=true; }
for (m=temp.options.length-1;m>0;m--) //这个for循环将opt_city中的内容清空
for (i=0;i<group[x].length;i++){ //这个for循环将opt_city中的内容更新成北京、东京、汉城
html表单属性,查看html教程,百度上去搜,有一大堆
function redirect(x){
for (m=temp.options.length-1;m>0;m--) //这个for循环是为了清空这个opt_city下拉框组,其实整个for可以用temp.length = 0;来代替,更快
temp.options[m]=null;
for (i=0;i<group[x].length;i++){ //这个for是添加新的OPTION组进去,最后选中第一个.
temp.options[i]=new Option(group[x][i].text,group[x][i].value);}
temp.options[0].selected=true;
}