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