循环!
for(i=0;i<parseInt(num.value);i++)
  alert(eval("n"+i).value)

解决方案 »

  1.   

    <script>
    function checkText(form)
    {
        var oText = document.getElementByTagName("INPUT");    
        for(i=0; i<oText.length; i++)
        {
            if (oText[i].type == "text")
            {
                if (!oText[i].value.match(/^(0\.)?\d+$/))
                    alert("不合法");
            }
        }
    }
    </script>
    <input type='button' onclick='checkText(this.form)' value='check'>
      

  2.   

    <form name=form1 method=post action="" >
    <input type="hidden"name=n value=5>
    <input type="text" name="n0">
    <input type="text" name="n1">
    <input type="text" name="n2">
    <input type="text" name="n3">
    <input type="text" name="n4"><input type="button" onclick="getValue()" value="getValue">
    </form><script language="JavaScript">
    <!--
    function getValue()
    {
    var n = parseInt(form1.n.value);
    for(var i=0;i<n;i++)
    {
    var tmp = form1.all("n" + i);
    alert(tmp.value)
    if(parseFloat(tmp.value)>0)
    {
    alert("大于0")
    }
    }
    }
    //-->
    </script>