日期:2014-05-16 浏览次数:20402 次
<select onchange="A(this)" name="STy1" id="STy1" size="1"><option value="sn" selected="true">Family/Last Name</option><option value="cn">Full Name</option><option value="id">ID</option></select>
<select name="SLk1" id="SLk1" size="1"><option value="OBW">That Begins With</option><option value="OOS">That Contains</option><option value="OEM">That Equals</option></select>
<select onchange="A(this)" name="STy1" id="STy1" size="1"> <option value="sn" selected="true">Family/Last Name</option> <option value="cn">Full Name</option> <option value="id">ID</option> </select> <select name="SLk1" id="SLk1" size="1"> <option value="OBW">That Begins With</option> <option value="OOS">That Contains</option> <option value="OEM">That Equals</option></select> <script type="text/javascript"> var opt = []; function A(obj) { var sel = document.getElementById('SLk1'); if (obj.value == 'id') { if (opt.length == 0) { opt[0] = sel.options[0]; opt[1] = sel.options[1]; } //存储起来,IE不支持option的style="display:none" //删除1,2项 sel.removeChild(sel.options[0]); sel.removeChild(sel.options[0]); } else if (sel.options.length == 1) { //重新添加1,2项 sel.insertBefore(opt[0],sel.options[0]); sel.insertBefore(opt[1], sel.options[1]); sel.selectedIndex = 0; } } </script>
------解决方案--------------------
<html> <head> <title>demo</title> </head> <body> <select onchange="A(this)" name="STy1" id="STy1" size="1"> <option value="sn" selected="selected" show="OBW,OOS,OEM" defvalue="OBW">Family/Last Name</option> <option value="cn" show="OBW,OOS,OEM" defvalue="OBW">Full Name</option> <option value="id" show="OEM" defvalue="OEM">ID</option> </select> <select name="SLk1" id="SLk1" size="1"> <option value="OBW">That Begins With</option> <option value="OOS">That Contains</option> <option value="OEM">That Equals</option> </select> <script type="text/javascript"> var Ori = { STy1: "STy1", SLk1Id: "SLk1", SLk1: [], Init: function() { var obj = document.getElementById(this.SLk1Id); var list = []; if (obj) { for (var i = 0; i < obj.options.length; i++) { list[i]