<br><input type="checkbox" name="shit" value="1" id="1" onclick="changeSel()">aaa
<br><input type="checkbox" name="shit" value="1" id="2" onclick="changeSel()">bbb
<br><input type="checkbox" name="shit" value="1" id="3" onclick="changeSel()">ccc
<br><input type="checkbox" name="shit" value="1" id="4" onclick="changeSel()">bbb
<br><select size="1" name="abc">        </select>
<script>
function changeSel()
{
for(i=0;i<abc.options.length;i++)
{
if(abc.options[i].text==event.srcElement.nextSibling.nodeValue)
return
}
abc.options[abc.options.length] = new Option(event.srcElement.nextSibling.nodeValue,event.srcElement.value)
}
</script>

解决方案 »

  1.   

    function changeSel(strName)
    {
    var objs = document.getElementsByName(strName), objSelect = document.getElementsByName("abc")[0], thisObj = null;
    while(objSelect.options.length>0)objSelect.options.remove(0);
    for(var i=0; i<objs.length; i++)
    {
    thisObj = objs[i];
    if(thisObj.checked)objSelect.options.add(new Option(thisObj.dispname,thisObj.value));
    }
    }
    </SCRIPT>
    <br><input type="checkbox" name="shit" value="value1" id="1" dispname="aaa" onclick="changeSel(name)">aaa
    <br><input type="checkbox" name="shit" value="value1" id="2" dispname="bbb" onclick="changeSel(name)">bbb
    <br><input type="checkbox" name="shit" value="value1" id="3" dispname="ccc" onclick="changeSel(name)">ccc
    <br><input type="checkbox" name="shit" value="value1" id="4" dispname="bbb" onclick="changeSel(name)">bbb
    <br><select size="1" name="abc"></select>
      

  2.   

    <form name=form1>
    <br><input type="checkbox" name="shit" value="1" onclick="changeSel(this)">aaa
    <br><input type="checkbox" name="shit" value="1" onclick="changeSel(this)">bbb
    <br><input type="checkbox" name="shit" value="1" onclick="changeSel(this)">ccc
    <br><input type="checkbox" name="shit" value="1" onclick="changeSel(this)">ddd<br><select size="1" name="abc"></select></form><SCRIPT LANGUAGE="JavaScript">
    function changeSel(e)
    {
      var p = e.parentNode;
      var s = document.form1.abc.options;
      s.length = 0;
      var a = document.getElementsByName(e.name);
      for(var i=0; i<a.length; i++)
        if(a[i].checked)
          mm(a[i], p, s);
    }
    function mm(e, p, s)
    {
      var n = p.childNodes.length;
      for(var i=0; i<n; i++)
      {
        if(p.childNodes[i]==e)
        {
          var t = p.childNodes[i+1];
          var str = t.nodeType==3 ? t.toString() : e.value;
          s[s.length] = new Option(str, e.value, true, true);
          break;
        }
      }
    }
    </SCRIPT>
      

  3.   

    <script language=javascript>
        function changeSel(txt)
        {
        var obj=document.all.abc;
        obj.options.add(new Option( txt,txt,true,true  )   );
        }
        </script>
    <form name=form>
     <br><input type="checkbox" name="shit" value="aaa" id="1" onclick="changeSel(this.value)">aaa
        <br><input type="checkbox" name="shit" value="bbb" id="2" onclick="changeSel(this.value)">bbb
        <br><input type="checkbox" name="shit" value="ccc" id="3" onclick="changeSel(this.value)">ccc
        <br><input type="checkbox" name="shit" value="ddd" id="4" onclick="changeSel(this.value)">bbb<br><select  name="abc">    
            </select></form>
      

  4.   

    <!--仅供参考-->
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    function changeSel(obj,str){
    var oSel=document.all.abc;
    if(obj.checked){
    oSel.add(new Option(str,obj.value));
    }
    else{
    for(var i=0;i<oSel.length;i++){
    if(oSel.value==obj.value) oSel[i]=null;
    }
    }
    }
    </script>
    </head><body>
    <br><input type="checkbox" name="shit" value="1" id="1" onclick="changeSel(this,'aaa')">aaa
        <br><input type="checkbox" name="shit" value="1" id="2" onclick="changeSel(this,'bbb')">bbb
        <br><input type="checkbox" name="shit" value="1" id="3" onclick="changeSel(this,'ccc')">ccc
        <br><input type="checkbox" name="shit" value="1" id="4" onclick="changeSel(this,'bbb')">bbb <br><select size="1" name="abc">    
            </select>
    </body>
    </html>
      

  5.   

    <style>
    input{t:expression(this.onclick=function(){changeSel()})}
    </style>
    <script>
    function changeSel()
    {
    var sel=document.getElementsByName("abc")[0];
    var obj=event.srcElement;if(obj.checked)
    {
      for(i=0;i<sel.options.length;i++)
       {
         if(sel.options[i].text==obj.nextSibling.nodeValue)
         return;
       }
      sel.options[sel.options.length] = new Option(obj.nextSibling.nodeValue,obj.value,false,false);
    }
    else
    {
      for(i=0;i<sel.options.length;i++)
       {
         if(sel.options[i].text==obj.nextSibling.nodeValue)
           sel.options[i]=null;
       }
    }
    }</script><body>
    <br><input type="checkbox" name="shit” value="1" id="1">aaa
        <br><input type="checkbox" name="shit" value="1" id="2">bbb
        <br><input type="checkbox" name="shit" value="1" id="3">ccc
        <br><input type="checkbox" name="shit" value="1" id="4">bbb<br><select size="1" name="abc">    
            </select>
    </body>