1.var theBoxes=document.getElementsByName("checkboxName");//得到一个对象数组
2.theBoxes[i].parentElement.parentElement.all("inputName");//得到同一行的input

解决方案 »

  1.   

    第一那里的checkBoxName是什么?我要根据table名得到这些checkbox元素哦
    第二那里的i和inputName是什么?我知道的就只是checkbox的引用,想得到同行的text的引用
    可能我没有说清楚,可否再为我解释一下?谢谢
      

  2.   

    1地解决<script language="javascript">
    <!--
    function check_box() {
        var Cbox=document.forms['form1'].elements['p[]'];
        if (Cbox.length != undefined){
            for(var i=0;i<=Cbox.length-1;i++)
                if(Cbox(i).type=='checkbox' && Cbox(i).checked==false)Cbox(i).value=0;
        }
    }
    function GetValue(){
        var Cbox=document.forms['form1'].elements['p[]'];
        var vas='';
        if (Cbox.length != undefined){
            for(var i=0;i<=Cbox.length-1;i++)
                  vas+=Cbox[i].value+',';
          }
        return vas;
    }
    //-->
    </script>
    <form name="form1" method="post" action="" onSubmit="return check_box();">
    <p>
    <input name="p[]" type="checkbox" onclick="check_box();" id="p[0]" value="ok">
    <input name="p[]" type="checkbox" onclick="check_box();" id="p[1]" value="ok">
    <input name="p[]" type="checkbox" onclick="check_box();" id="p[2]" value="ok">
    </p>
    <p>
    <input type="submit" name="Submit" value="TEST" onclick="alert(GetValue());">
    </p>
    </form>
      

  3.   

    你要根据名来的呀。
    <input type=checkbox name=che1><input type=text name=fie1><br>
    <input type=checkbox name=che2><input type=text name=fie2><br>
    <input type=checkbox name=che3><input type=text name=fie3><br>
    <input type=checkbox name=che4><input type=text name=fie4><br>
    <input type=checkbox name=che5><input type=text name=fie5><br>
    .
    .
    .   可以用getElementsByTagName("checkBox")得到所有checkboxd的数组,然后你就可以用一定的方法对这个数组进行遍历了。
       对于你的第二个问题,我想,没有线程的方法,也不可能又现成的方法。不过你可以通过名字来,就像我上面写的,che1对应fie1...
      

  4.   

    你得到checkBox的名字后,比如是chei,那么你可以进行下面的处理,来得到相应的fiei:
    var cheName;//是checkBox的名字chei
    var i=eval(cheName.charAt(3));
    var fieName = "fie" + i;//得到fiei
      

  5.   

    to sunnybay(日光海岸) :
    怎么不见有table的?我要得到属于某表格"table0"内的所有的checkbox哦to changpei(张枕书) :
    checkbox和text都是动态生成的,不好命名啊
    我想不是根据名字来找,是根据它们位于"table0"的同一行这个关系来找
      

  6.   

    1.
    <script language="javascript">
    <!--
    function check_box() {
        var Cbox=document.forms['form1'].elements['p[]'];
        if (Cbox.length != undefined){
            for(var i=0;i<=Cbox.length-1;i++)
                if(Cbox(i).type=='checkbox' && Cbox(i).checked==false)Cbox(i).value=0;
        }
    }
    function GetValue(){
        var Cbox=document.forms['form1'].elements['p[]'];
        var vas='';
        if (Cbox.length != undefined){
            for(var i=0;i<=Cbox.length-1;i++)
                  vas+=Cbox[i].value+',';
          }
        return vas;
    }
    //-->
    </script><table>
    <tr>
    <td>
    <form name="form1" method="post" action="" onSubmit="return check_box();">
    <p>
    <input name="p[]" type="checkbox" onclick="check_box();" id="p[0]" value="ok">
    <input name="p[]" type="checkbox" onclick="check_box();" id="p[1]" value="ok">
    <input name="p[]" type="checkbox" onclick="check_box();" id="p[2]" value="ok">
    </p>
    <p>
    <input type="submit" name="Submit" value="TEST" onclick="alert(GetValue());">
    </p>
    </form>
    </td>
    </tr>
    </table>2.解决办法可以对checkbox和text有规则命名,比如chk01和text01这样你找到chk01是只要把01取出来,然后做个函数把(01)传递进去
    function 函数名(no) {
      //给对应的TEXT赋值 
      document.getElementById("text"+no).value = *****;
    }