如何让select的option不可见。
请教:
有二个相同的select option选项。
就是说当选中每一 个select的子项,对应在第二个option的这个选项要不可见,怎么实现。
例如:二个相同的select如下。
<select name="t">
<option value=a>a</option>
<option value=b>b</option>
<option value=c>c</option>
<option value=d>d</option>
<option value=e>e</option>
</select>
[解决办法]
<SCRIPT LANGUAGE="JavaScript">function a(t1){ var t2 = document.getElementsByName("t")[1]; t2.options.length=0; var j=0; for(var i=0;i<t1.options.length ;i++ ) { if(i!=t1.selectedIndex) { t2.options[j] = new Option(t1.options[i].text,t1.options[i].value); j++; } }}</SCRIPT><select name="t" onchange="a(this)"> <option value=a>a </option> <option value=b>b </option> <option value=c>c </option> <option value=d>d </option> <option value=e>e </option></select><select name="t"> <option value=a>a </option> <option value=b>b </option> <option value=c>c </option> <option value=d>d </option> <option value=e>e </option></select>
[解决办法]
<!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> function setqq(a){ document.getElementById(a).style.visibility="hidden"; } </script> </HEAD> <BODY> <div id="t1" style="visibility:visible"> <select onchange="setqq('t2')"> <option value=a>a </option> <option value=b>b </option> <option value=c>c </option> <option value=d>d </option> <option value=e>e </option> </select></div><br/><div id="t2" style="visibility:visible"><select onchange="setqq('t1')"> <option value=a>a </option> <option value=b>b </option> <option value=c>c </option> <option value=d>d </option> <option value=e>e </option> </select></div> </BODY></HTML>