<%@ page contentType="text/html"%>
<form method=post>
<input name=x value=''>
<script>
function _change()
{
var rnd=""; for(var i=0;i<12;i++)
rnd+=Math.floor(Math.random()*10);
document.all.x.value=rnd;
}
_change();
</script>
<%
String x=request.getParameter("x");
System.out.println("the value X is :"+x);
%>
</form>
<form method=post>
<input name=x value=''>
<script>
function _change()
{
var rnd=""; for(var i=0;i<12;i++)
rnd+=Math.floor(Math.random()*10);
document.all.x.value=rnd;
}
_change();
</script>
<%
String x=request.getParameter("x");
System.out.println("the value X is :"+x);
%>
</form>
<form method=post>
<input name=y value=''>
<script>
function _change1()
{
document.all.y.value="this is a test";
}
_change1();
</script>
<%
String y=request.getParameter("y");
System.out.println("the value Y is :"+y);
%>
</form>
但是为什么这样可以打印the value Y is :this is a test呢??
<form method=post>
<input name=y value=''>
<script>
function _change1()
{
document.all.y.value="this is a test";
}
_change1();
</script>
<%
String y=request.getParameter("y");
out.println("the value Y is :"+y);
%>
</form>
不信打到前台看看
加个<input type = "submit">即可