function setCity(flag){ var fm; var contry; var city; if(flag<=3){ fm = document.form; }else{ fm = document.form1; } if(flag=='0'){ contry = fm.startContry.value; city = fm.startCity; }else if(flag=='1'){ contry = fm.toContry.value; city = fm.toCity; }else if(flag=='2'){ contry = fm.backContry.value; city = fm.backCity; }else if(flag=='3'){ contry = fm.backToContry.value; city = fm.backToCity; } switch(contry){ case '1': var labels = new Array("東京(羽田)","大阪(全て)","大阪(伊丹)","大阪(関西)"); var values = new Array("東京(羽田)","大阪(全て)","大阪(伊丹)","大阪(関西)"); break; case '2': var labels = new Array("上海(浦東虹橋)","上海(浦東)","上海(虹橋)","北京","広州"); var values = new Array("上海(浦東虹橋)","上海(浦東)","上海(虹橋)","北京","広州") break; case '3': var labels = new Array("台湾(桃園松山)","台湾(桃園)","台湾(松山)","高雄"); var values = new Array("台湾(桃園松山)","台湾(桃園)","台湾(松山)","高雄"); break; case '4': var labels = new Array("香港"); var values = new Array("香港"); break; case '5': var labels = new Array("ソウル(仁川金浦)","ソウル(仁川)","ソウル(金浦)","釜山"); var values = new Array("ソウル(仁川金浦)","ソウル(仁川)","ソウル(金浦)","釜山"); break; } city.options.length=0; for(var i=0;i<labels.length;i++){ city.add(document.createElement("option")); city.options[i].text = labels[i]; city.options[i].value = values[i]; } city.selectedlndex = 0; } 这个JS函数更完善,当一个页面有多个重复的下拉列表时候,而且他们的name都不同,可以通过传递参数来判断到底是哪一个下拉列表框,最后不要忘了在body结束后调用一下setCity(参数); |