J.J.
J.J.

Reputation: 1118

Why is javascript failing to get form value?

I am attempting to retrieve this value from the form, but it isn't returning anything. How should this be fixed? Can anyone point me in the right direction?

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;
  }
}

Upvotes: 0

Views: 54

Answers (1)

Joey Yi Zhao
Joey Yi Zhao

Reputation: 42418

Please try to use array to acces the value:

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

Upvotes: 5

Related Questions