为什么javascript无法获得表单值?

时间:2015-10-14 07:42:22

标签: javascript html

我试图从表单中检索此值,但它没有返回任何内容。该如何修复?有人能指出我正确的方向吗?

function checkForm()
{
  numrows = document.theform.numrows.value;
  if(numrows == -1)
  {
    alert("You have not chosen any options yet");
    return false;
  }

  emailcheckcount = 0;
  for(i=0; i<=numrows; i++)
  {
      var recid = document.theform.recid'+i+'.value; //why is this failing to get value here?
      alert("Test" + recid);
      return false;
  }
}

1 个答案:

答案 0 :(得分:5)

请尝试使用数组来访问值:

var recid = document.theform.recid[i].value;