<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
function bbb()
{
var s1 = document.getElementById("Select2");
var o = s1.getAttribute("value");
var cbo = document.getElementById("select1");
for(var i=0;i<cbo.options.length;i++)
{
cbo.options.remove(i);
}
if(o=="1")
{
var o1 = document.createElement("option");
o1.innerHTML = "abc";
o1.setAttribute("value","1");
var o2 = document.createElement("option");
o2.innerHTML = "abc1";
o2.setAttribute("value","3");
var o3 = document.createElement("option");
o3.innerHTML = "abc2";
o3.setAttribute("value","2");
var s2 = document.getElementById("select1");
s2.appendChild(o1);
s2.appendChild(o2);
s2.appendChild(o3);
}
else
{
cbo.options.remove(0);
}
}
</script>
<body οnlοad="bbb();">
<form id="form1" name="form1" method="post" action="">
<label>
<select name="select" id="select1">
</select>
</label> <input type="button" value="asd" οnclick="bbb();" style="width: 57px" />
<select id="Select2" οnchange="bbb();" name="D1">
<option value="1">A</option>
<option value="2">B</option>
</select></form>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
function bbb()
{
var s1 = document.getElementById("Select2");
var o = s1.getAttribute("value");
var cbo = document.getElementById("select1");
for(var i=0;i<cbo.options.length;i++)
{
cbo.options.remove(i);
}
if(o=="1")
{
var o1 = document.createElement("option");
o1.innerHTML = "abc";
o1.setAttribute("value","1");
var o2 = document.createElement("option");
o2.innerHTML = "abc1";
o2.setAttribute("value","3");
var o3 = document.createElement("option");
o3.innerHTML = "abc2";
o3.setAttribute("value","2");
var s2 = document.getElementById("select1");
s2.appendChild(o1);
s2.appendChild(o2);
s2.appendChild(o3);
}
else
{
cbo.options.remove(0);
}
}
</script>
<body οnlοad="bbb();">
<form id="form1" name="form1" method="post" action="">
<label>
<select name="select" id="select1">
</select>
</label> <input type="button" value="asd" οnclick="bbb();" style="width: 57px" />
<select id="Select2" οnchange="bbb();" name="D1">
<option value="1">A</option>
<option value="2">B</option>
</select></form>
</body>
</html>