日期:2014-05-16  浏览次数:20394 次

javascript如何循环读取页面中文本框的值?
<%
        for(int   i;i <5;i++){
%>
<input   type= "text "   name= " <%=i%> "   value= " <%=i%> ">
<script>
          //输出文本框的值
</script>
<%
      }
%>
急!!!弄了好久,搞不定!在线等!

------解决方案--------------------
<body>
<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test= "${param.sayHello} ">
<!-- Let 's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>
<form action= " " method= "post ">
<%for(int i=0;i <10;i++){%>
<input type= "text " name= " <%=i%> " value= " ">
<%}%>
<input type= "button " value= "click " onclick= "test(); ">
<input type= "text " name= "a " value= "aaaa ">
</form>
<script language= "javascript ">
test=function()
{
alert(document.getElementsByName( "1 ")[0].value);
}

</script>
</body>
------解决方案--------------------
<%
for(int i;i <5;i++){
%>
<input type= "text " name= "km <%=i%> " id= "km <%=i%> " value= " <%=i%> ">
<script>
var i = <%=i%>
for(k=0;k <i + 1;k++){
alert(document.all( "km " + k).value)
}

//输出文本框的值
</script>
<%
}
%>