Jquery Typeerror变量未定义

时间:2013-02-09 11:29:08

标签: jquery

我尝试在输入时动态创建行。我得到TypeError:arrDetail [tempcount]未定义。我正在使用firefox最新版本。我想知道它是浏览器问题还是编码问题。帮助是赞赏。提前致谢。 我的代码如下:

function makeDivTag(St)
{
    //alert("makediv");
     alert("tempcount");
        var i ;
        //var num = Number(document.getElementById("divLst_count").value) + 1;

    //var divIdName = "my"+(num-1)+"Div";
    var divName=0;
    strHTML = '';
    alert("selitem makediv" + selItem);
    if (selItem == -1)
    {
        alert("in for");
      for(i=0;i<=arrCount;i++)
      {
        divName= "my" + tempcount +"Div";
        strHTML = strHTML +"<TR id="+divName+">";
        strHTML = strHTML +"<TD><INPUT type=\"text\" class=\"divtext\" style=\"width:100;text-align:left;\" name=\"lstacode[]\"  id=\"lstacode[]\" value='"+ arrDetail[tempcount][1] +"'></TD>";

        strHTML = strHTML +"<TD><INPUT type=\"text\" class=\"divtext\" style=\"width:300;text-align:left;\" name=\"lstaccountname[]\" value='"+ arrDetail[tempcount][2] +"'></TD>";

        strHTML = strHTML +"<TD><INPUT type=\"text\" class=\"divtext\" style=\"width:90;text-align:left;\" name=\"lstamount[]\" value='"+ arrDetail[tempcount][5] +"'></TD>";
        strHTML = strHTML +"<INPUT type=\"hidden\" name=\"lstremarks[]\" value='"+ arrDetail[tempcount][7] +"'>";

        strHTML = strHTML +"<INPUT type=\"hidden\" name=\"lstprev_acode[]\" value='"+ arrDetail[tempcount][8] +"'>";


        if (St=='0')
        {

            strHTML = strHTML +"<TD><INPUT type=\"button\" name=\"V\" class=\"lstButton\" value=\"View\" onClick=\"displayDivRow(document.frmcashpayment,'"+ tempcount +"');\" ></TD>";
        }
        else
        {

            strHTML = strHTML +"<TD><INPUT type=\"button\" name=\"E\" style=\"width:20;\" class=\"lstButton\" value=\"M\" onClick=\"displayDivRow(document.frmcashpayment,'"+ tempcount +"');\">";


            strHTML = strHTML +"<INPUT type=\"button\" name=\"D\" style=\"width:20;\" class=\"lstButton\" value=\"D\" onClick=\"removeDivRow(document.frmcashpayment,'"+ tempcount +"');\"></TD>";
        }
        strHTML = strHTML +"</TR>";
    }

    $("#divList > tbody").append(strHTML);
    }
    else
    {
         alert("selitem in makediv else" + selItem);
         alert(document.getElementById('hidacode').value);
        document.getElementsByName("lstacode[]")[selItem].value = document.getElementById('hidacode').value;
        document.getElementsByName("lstaccountname[]")[selItem].value = document.getElementById('txtaccountname').value;
        document.getElementsByName("lstamount[]")[selItem].value = document.getElementById('txtamount').value;
        document.getElementsByName("lstremarks[]")[selItem].value = document.getElementById('txtremarks').value;

    }
    //$("#divList > tbody").append(strHTML);
}

我正在动态尝试在输入时创建行。感谢帮助。提前谢谢。

0 个答案:

没有答案