日期:2014-05-17 浏览次数:20727 次
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'test2.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
var c=0
var t
function start()
{
document.getElementById('txt1').value=Math.round(Math.random() * (500- 1) + 1);
document.getElementById('txt2').value=Math.round(Math.random() * (500- 1) + 1);
t=setTimeout("start()",60)
}
function over(){
clearTimeout(t);
document.getElementById('txt1').value=<%=r[0]%>//这样写有错误啊 。。。
}
</script>
</head>
<body>
<%
Random C=new Random();
int r[]=new int[100];
for(int i=0;i<20;i++)
{
r[i]=C.nextInt(500);
for(int a=0;a<i;a++)
{
if(i==0)
{
break;
}
if(r[i]==r[a])
{
i--;
break;
}
}
}
for(int u=0;u<r.length;u++)
System.out.print(r[u]+",");
%>
<input type="text" id="txt1" value="" />
<input type="text" id="txt2" value="" />
<input type="button" onclick="start()" value="开始"/>
<input type="but