87,992
社区成员
发帖
与我相关
我的任务
分享<script language="JavaScript">
// 这个数组存放所有的Option选项
var arr = new Array(new Array("A","0"),
new Array("B","1"),
new Array("C","2"),
new Array("D","3"),
new Array("E","4")
);
function ck(obj){
var to;
if(obj.name == "a" || obj.id == "a"){
to = document.getElementById("b");
} else {
to = document.getElementById("a");
}
to.length = 0;
for(var i=0;i<arr.length;i++){
if(obj.selectedIndex < 0 || arr[i][1] != obj.options[obj.selectedIndex].value){
var opn = new Option(arr[i][0],arr[i][1]);
to.options.add(opn);
}
}
to.selectedIndex = 0;
}
</script>
<body onload="ck(document.getElementById('b'));ck(document.getElementById('a'));">
<form>
<select name="a" onchange="ck(this)">
</select>
<select name="b" onchange="ck(this)">
</select>
</form>
</body>
<script language="JavaScript">
function ck(sel){
alert(sel.options[sel.selectedIndex].text);
document.forms[0].b.options.remove(sel.options[sel.selectedIndex].value);
}
</script>
<body>
<form name="tradeSellForm">
<select name="a" onchange="ck(this)">
<option value="0">A </option>
<option value="1">B </option>
<option value="2">C </option>
</select>
<select name="b" >
<option value="0">A </option>
<option value="1">B </option>
<option value="2">C </option>
</select>
</form>
</body>
<script language="JavaScript">
var cur;
function ck(sel){
var m1=document.tradeSellForm.a.selectedIndex;
var m2=document.tradeSellForm.b.selectedIndex;
if(m1==m2){
alert("不能相同");
sel.selectedIndex = cur;
}
}
</script>
<body>
<form name="tradeSellForm">
<select name="a" onfocus="cur=this.selectedIndex;" onchange="ck(this)">
<option value="0">A </option>
<option value="1">B </option>
<option value="2">C </option>
</select>
<select name="b" onfocus="cur=this.selectedIndex;" onchange="ck(this)">
<option value="0">A </option>
<option value="1" selected="true">B </option>
<option value="2">C </option>
</select>
</form>
</body>