2015-10-14 46 views
0

我试图从窗体中检索这个值,但它没有返回任何东西。这应该如何解决?任何人都可以将我指向正确的方向吗?为什么javascript无法获得表单值?

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

该行的语法document.theform.recid '+ I +' 值不正确。您是否检查过浏览器日志以获取任何错误消息。 考虑添加一个HTML表单的代码片段,这个函数被调用,所以有人想要回答可能有更多的信息。另请注明您是否收到警报。如果您使用的是Firefox/Chrome浏览器,请尝试使用console.log来打印一些调试消息。 – vvs

回答

5

请尽量使用数组来存取权限值:

var recid = document.theform.recid[i].value; 
相关问题