<input type="checkbox" name="a" id="a " value="1">
<input type="checkbox" name="a" id="a " value="2">
<input type="checkbox" name="a" id="a " value="3">
......
<input type="checkbox" name="a" id="a " value="n"><input type="text" name="b"><input type="button" name="确定" onclick="for (i=0;i<a.length;i++) b.value+=a[i]+' ';" value="确定">以上IE适用 FF得稍加修改

解决方案 »

  1.   

    上面有一处漏写,以下正确(测试过)
    <input type="checkbox" name="a" id="a " value="1">
    <input type="checkbox" name="a" id="a " value="2">
    <input type="checkbox" name="a" id="a " value="3">
    ......
    <input type="checkbox" name="a" id="a " value="n"><input type="text" name="b"><input type="button" name="确定" onclick="for (i=0;i<a.length;i++) b.value+=a[i].value+' ';" value="确定">以上IE适用 FF得稍加修改
      

  2.   

    我是想要,被选中的checkbox的值,放到文本框里,没选中的值不放进去~~
      

  3.   

    这有何难, 以下就是:
    <input type="checkbox" name="a" id="a " value="1">
    <input type="checkbox" name="a" id="a " value="2">
    <input type="checkbox" name="a" id="a " value="3"><input type="text" name="b"><input type="button" name="确定" onclick="for (i=0;i<a.length;i++) b.value+=a[i].checked?a[i].value+' ':'';" value="确定">
      

  4.   

    <script>
        function check(){
          b.value = "";     
          for (i=0;i<a.length;i++){
          if(a[i].checked)
          b.value+=a[i].checked?a[i].value+' ':'';
         }    
        }
    </script>
    <input type="checkbox" name="a" id="a " value="1">
    <input type="checkbox" name="a" id="a " value="2">
    <input type="checkbox" name="a" id="a " value="3"><input type="text" name="b"><input type="button" name="确定" onclick="check()" value="确定">
      

  5.   

    这有何难, 以下就是:
    <input type="checkbox" name="a" id="a " value="1">
    <input type="checkbox" name="a" id="a " value="2">
    <input type="checkbox" name="a" id="a " value="3"><input type="text" name="b"><input type="button" name="确定" onclick="b.value='';for (i=0;i<a.length;i++) b.value+=a[i].checked?a[i].value+' ':'';b.value==''?alert('You should check someone'):alert('Nice job')" value="确定">
      

  6.   

    =======================如下代码就不能执行,怎么改造?==就一个checkbox<script>
        function check(){
          b.value = "";     
          for (i=0;i<a.length;i++){
          if(a[i].checked)
          b.value+=a[i].checked?a[i].value+' ':'';
         }    
        }
    </script>
    <input type="checkbox" name="a" id="a " value="1">
    <input type="text" name="b"><input type="button" name="确定" onclick="check()" value="确定">
      

  7.   

    <input type="checkbox" name="a" id="a " value="1">
        <input type="checkbox" name="a" id="a " value="2">
        <input type="checkbox" name="a" id="a " value="3">
    <input type="text" name="b">
    <input type="button" name="确定" onclick="check()" value="确定">    function check(){
            var b=document.form_MAIN.b;
            b.value = "";
            var flag=0;
            a=document.getElementsByName("a");
            for (i=0;i<a.length;i++){
             if(a[i].checked){
             b.value+=a[i].checked?a[i].value+' ':'';
             flag=1;
             alert(b.value);
             }
            }
            if(flag == 0){
             alert("NO checked");
            }
        }