|
网页中的下拉列表联动,比如选择国家时,选择中国,另一个下拉框显示出中国的城市,选择美国时,显示美国的城市。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""><SCRIPT LANGUAGE="JavaScript"><!--window.onload = function changedrop2(){ if(document.form1.drop1.selectedIndex==0){ document.form1.drop2.length=1; document.form1.drop2.options[0].text="请选择国家"; document.form1.drop2.options[0].value="none"; } else if(document.form1.drop1.value=="chn"){ document.form1.drop2.length=3; document.form1.drop2.options[0].text="山东"; document.form1.drop2.options[0].value="sd"; document.form1.drop2.options[1].text="上海"; document.form1.drop2.options[1].value="sh"; document.form1.drop2.options[2].text="北京"; document.form1.drop2.options[2].value="bj"; } else if(document.form1.drop1.value=="us"){ document.form1.drop2.length=3; document.form1.drop2.options[0].text="华盛顿"; document.form1.drop2.options[0].value="h"; document.form1.drop2.options[1].text="休斯顿"; document.form1.drop2.options[1].value="hou"; document.form1.drop2.options[2].text="洛杉矶"; document.form1.drop2.options[2].value="l"; } else if(document.form1.drop1.value=="en"){ document.form1.drop2.length=2; document.form1.drop2.options[0].text="伦敦"; document.form1.drop2.options[0].value="l"; document.form1.drop2.options[1].text="曼彻斯特"; document.form1.drop2.options[1].value="m"; }}//--></SCRIPT> </HEAD> <BODY> <form name="form1"> <select name="drop1" onchange="javascript:changedrop2()" size="1"><option selected value="default">国家</option><option value="chn">中国</option><option value="us">美国</option><option value="en">英国</option> </select></br> <select name="drop2" size="1"> </select> </form> </BODY></HTML> |
|