都是a组的,又是单选框,如何实现全选??  如果改组名,那还不如用checkbox.

解决方案 »

  1.   


    <br><input type=checkbox name="a">a  <input type=checkbox name="b">b
    <br><input type=checkbox name="a">a  <input type=checkbox name="b">b
    <br><input type=checkbox name="a">a  <input type=checkbox name="b">b
    <br><input type=checkbox name="a">a  <input type=checkbox name="b">b
    <br><input type=checkbox name="a">a  <input type=checkbox name="b">b
    <br><input type=checkbox name="a">a  <input type=checkbox name="b">b
    <br>全选A<input type=checkbox onclick="selectAllCheckboxes('a',this.checked);">
    <br>全选B<input type=checkbox onclick="selectAllCheckboxes('b',this.checked);"><script>
    /**
    * This function is to change all checkboxes to checked or unchecked.
    * JK 2003-12-08
    */
    function selectAllCheckboxes(nameOfCheckBox,trueOrFalse)
    {
    if(trueOrFalse==null) trueOrFalse=true;
    var theCheckboxInputs=document.getElementsByName(nameOfCheckBox);
    for (var i=0;i<theCheckboxInputs.length;i++)
    theCheckboxInputs[i].checked=trueOrFalse;
    }
    </script>
      

  2.   

    function selecta()
    {
       var objs = document.getElementsByName('a');
        var i=0;
        for(i = 0 ; i < objs.length ;  i ++)
        {
          if(objs[i].checked ==true)
          {   
               objs[i].checked =false; 
          }
          else
            {
                objs[i].checked =true; 
             }
        }
    }function selectb()
    {
       var objs = document.getElementsByName('b');
        var i=0;
        for(i = 0 ; i < objs.length ;  i ++)
        {
          if(objs[i].checked ==true)
          {   
               objs[i].checked =false; 
          }
          else
            {
                objs[i].checked =true; 
             }
        }
    }
      

  3.   

    <br><input type=radio name="a1">a  <input type=radio name="a1">b
    <br><input type=radio name="a2">a  <input type=radio name="a2">b
    <br><input type=radio name="a3">a  <input type=radio name="a3">b
    <br><input type=radio name="a4">a  <input type=radio name="a4">b
    <br><input type=radio name="a5">a  <input type=radio name="a5">b
    <br><input type=radio name="a6">a  <input type=radio name="a6">b
    <br>全选A<input type=radio name=JK onclick="selectAll(0)">
    <br>全选B<input type=radio name=JK onclick="selectAll(1)"><script>function selectAll(redioIndex)
    {
    for(var i=1;i<7;i++)
    document.all("a"+i)[redioIndex].checked=true;
    }
    </script>
      

  4.   

    radio 用来使用户来单选一个选项的checkbox  使用来给用户进行多选的!楼主何必非要绕弯路呢!