方法一
<head>
<title>Test</title>
<SCRIPT language=javascript>
<!--
function Test()
{
if (form_num.IsRun.value==1)
{
var number = Math.random();
number = number * 1000000000;
number = Math.ceil(number);
number_1=String(number);
if (number_1.length==9){
form_num.num.value = number;
form_num.num_1.value = number_1.length;
}
else{
return
}
}
}
//-->
</SCRIPT>
</head>
<body onLoad="setInterval('Test()',100)">
<form method="POST" action="" name="form_num">
<p>
<input type="text" name="num" size="20">
<input type="text" name="num_1" size="20">
<input type="hidden" name="IsRun" size="20" value="0">
<input name="stop" type="button" onClick="javascipt:form_num.IsRun.value=0;" value="停止">
<input name="start" type="button" id="start" onClick="javascipt:form_num.IsRun.value=1;" value="开始">
</p>
</form>
</body>
</html>
方法二
<script language="javascript" >
function RndNum(n)
{
var rnd="";
for(var i=0;i<n;i++)
rnd+=Math.floor(Math.random()*10);
return rnd;
}
alert(RndNum(9));
</script>
posted on 2006-04-03 15:46
汪杰 阅读(2689)
评论(0) 编辑 收藏 引用 所属分类:
hengxing网站js