您的位置:首页 > Web前端 > JavaScript

html5与JavaScript脚本的六位彩票随机数字算法

2016-07-15 18:16 531 查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>抽奖</title>
<style>
input{
width: 20px;
height: 20px;
}
[type="button"]{
width: 40px;
height: 20px;
}
</style>
<script>
var showNum;
window.onload=function(){
document.getElementById("start").onclick=function(){
showNum=setInterval(randomNum,100);
document.getElementById("stop").disabled=false;
this.disabled=true;
}
document.getElementById("stop").onclick=function(){
document.getElementById("start").disabled=false;
this.disabled=true;
window.clearInterval(showNum);
}
}
var randomNum=function(){
var result=document.getElementsByName("num");
for(var i=0;i<result.length;i++){
result[i].value=Math.floor(Math.random()*10);
}
}
</script>
</head>
<body>
<input type="text" name="num" value=""/>
<input type="text" name="num" value=""/>
<input type="text" name="num" value=""/>
<input type="text" name="num" value=""/>
<input type="text" name="num" value=""/>
<input type="text" name="num" value=""/>
<input type="button" value="开始" id="start"/>
<input type="button" value="停止" id="stop" disabled="disabled"/>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Tag html JavaScript CSS