<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script>
function getOptions(){
for(i =0;i<document.form1.s1.length;i++)//取单选框的值
{
if(document.form1.s1.options[0].selected==true){
// alert(1);
document.form1.s2.options.length=0;
document.form1.s2.options[0]=new Option('北京','1',false,false);
document.form1.s2.options[1]=new Option('上海','2',false,false);
document.form1.s2.options[2]=new Option('重庆','2',false,false);
}
if(document.form1.s1.options[1].selected==true){
// alert(1);
document.form1.s2.options.length=0;
document.form1.s2.options[0]=new Option('洛阳','1',false,false);
document.form1.s2.options[1]=new Option('郑州','2',false,false);
}
}
return true;
}
</script>
</head>
<body>
<form name="form1">
<select name="s1" onChange="getOptions()">
<option value="1" >直辖市</option>
<option value="2" >河 南</option>
</select>
<select name="s2">
<option value="1">北京</option>
<option value="2">上海</option>
<option value="3">重庆</option>
</select>
</form>
</body>
</html>
本文地址:http://com.8s8s.com/it/it31004.htm