取到以后,我的input框name为chqn加所在行数,如chqn1,chqn2,如何写这个名字,如判断this.document.pay.chqn1.value==''等等,怎么写

解决方案 »

  1.   

    <table>
    <tr><td><input type=text name=chqn1 value=a></td></tr>
    <tr><td><input type=text name=chqn2 value=b></td></tr>
    <tr><td><input type=text name=chqn3 value=c></td></tr>
    <tr><td><input type=text name=chqn4 value=d></td></tr>
    </table>
    <button onclick="dosomething()"> do some thing</button>
    <script language="JavaScript">
    <!--
    function dosomething(){
    for(var i=1; i<=4; i++){
     var e=eval("document.all.chqn" + i);
     alert(e.value);
    }
    }
      

  2.   

    这样写有什么错
    for (var i=1;i<=this.document.paychkpk2tr.post_col_num.value;i++)
    {
         var e=eval("this.document.paychkpk2tr.chqn" + i);
         if (e.value=='')
         {
               alert('支票号码 没有填写,请重新输入!'); 
               return false;
         }
    }
      

  3.   

    你这段代码应当是在某个函数中,不能用this代表window,因为this指的是函数本身。
      

  4.   

    这样那
    var i=this.document.paychkpk2tr.post_col_num.value;
    dosomething(i);                           
    function dosomething(var i){
     var e=eval("document.paychkpk2tr.chqn" + i);
     alert(e.value);
    }
    这段代码有错误,报脚本错
      

  5.   

    把document.paychkpk2tr.post_col_num相关代码贴出来
      

  6.   

    n=document.GetElementByTagName("td").length
      

  7.   

    <input type=hidden name=post_col_num value=<?php echo $i;?>>i=this.document.paychkpk2tr.post_col_num.value; 
    alert(i);
    i的值是2。
    var e=eval("document.paychkpk2tr.chqn" + i);
    alert(e.value);
    报错,但是如果是
    var e=this.document.paychkpk2tr.chqn2;
    alert(e.value);
    就能显示出正确的结果
      

  8.   

    var i=document.all.paychkpk2tr.post_col_num.value;
    alert(i);
    alert(eval("document.paychkpk2tr.chqn" + i+".value"));
      

  9.   

    goldenlove(潇洒.net) 的方法,第二个alert没有执行,只执行了第一个,但是也没有报错