js产生两组随机数,第一组产生不重复随机数组,第二组产生不包括第一组数据的不重复随机数...

js产生两组随机数,第一组产生不重复随机数组,第二组产生不包括第一组数据的不重复随机数

这是我在做下面的抽奖小系统才有这样的问题:
在test1.jsp在1-500中产生不重复随机数,比如第一组随机产生不重复随机两个数12,23,在第二个页面test2.jsp产

生的两个数中不包括12,23,该怎么实现(所有产生的数不重复)

//test1.jsp
<%@ 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 'tpl.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">
<script type="text/javascript" src="jQuery.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript">
var c=0
var t
function start()
{
var txt1=Math.round(Math.random() * (500- 1) + 1);
var txt2=Math.round(Math.random() * (500- 1) + 1);
document. getElementById('txt1').value=txt1;
document. getElementById('txt2').value=txt2;
t=setTimeout("start()",60)
}
function over()
{
clearTimeout(t);
}
</script>
</head>
<body>
<input type="text" id="txt1" style="width:60px;height:50px;font-size:30px;">
<input type="text" id="txt2" style="width:60px;height:50px;font-size:30px;">
<div class="start" ><img src="images/start1.png" onclick="start()"/></div>
<div class="over"><img src="images/over.png" onclick="over()" /></div>
</body>
</html>


//test2.jsp

<%@ 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 'tpl.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">
<script type="text/javascript" src="jQuery.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript">
function start()
{
var txt3=Math.round(Math.random() * (500- 1) + 1);
var txt4=Math.round(Math.random() * (500- 1) + 1);
document. getElementById('txt3').value=txt3;
document. getElementById('txt4').value=txt4;
t=setTimeout("start()",60)
}
function over()
{
clearTimeout(t);
}
</script>
</head>
<body>
<li><input type="text" id="txt3" style="width:60px;height:50px;font-size:30px;"></li>
<li><input type="text" id="txt4" style="width:60px;height:50px;font-size:30px;"></li>
<div class="start" ><img src="images/start1.png" onclick="start()"/></div>
<div class="over"><img src="images/over.png" onclick="over()" /></div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值