function checkattribinput(count){
   alert(count);
     for (i=0;i<count;i++){
       if (eval("document.form1.attribname"+(i+1).value==2){
         alert("属性名"+(i+1)+"不能为空,请输入");         return false;
       }
     }
     return true;
   }

解决方案 »

  1.   

    function checkattribinput(count){
       alert(count);
         for (i=0;i<count;i++){
           if (eval("document.form1.attribname"+(i+1)+".value==2")){
             alert("属性名"+(i+1)+"不能为空,请输入");         return false;
           }
         }
         return true;
       }
      

  2.   

    function checkattribinput(count){
       alert(count);
         for (i=0;i<count;i++){
           if (eval("document.form1.attribname"+(i+1)).value==2){
             alert("属性名"+(i+1)+"不能为空,请输入");         return false;
           }
         }
         return true;
       }
      

  3.   

    if (eval("document.form1.attribname"+(i+1)).value==2){USE eval
      

  4.   

    其实你的这样设计并不科学.在server端将需要很多附加操作..
    比较合理的是用相同的名字命名然后用如下的语句:
    function checkattribinput(){
         for (i=0;i<document.form1.all("attribname").length;i++)
         {
           if (document.form1.all("attribname")[i].value==2)
           {
             alert("属性名"+(i+1)+"不能为空,请输入");
             document.form1.all("attribname")[i].focus();
             return false;
           }
         }
         return true;
       }