当前位置:编程学习 > JS >>

简单的随机抽取系统--html--js

[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>无标题文档</title> 
<script type="text/javascript"> 
var names=new Array("蔡帅","常赛赛","陈晨","陈俊","陈磊","陈晓东","陈楠","杜广伟","段礼想","范晓峡","冯贺娟","高春发","高洋","葛阳","郭博","何素芳","何晓伟","胡军鹏","黄文春","惠媛佩","靳培强","李传允","李浩博","李俊锋","李乐乐","李品","李伟峰","李文博","李亚伟","李益芳","梁建","刘洪超","刘利丹","刘松松","罗凯凯","马王莹","苗珺杰","聂鹏英","秦仕朋","沈冬冬","石亚博","时宁","王高杨","王恒","王腾飞","王小洁","吴南","肖桦","杨琪琳","余洋","岳亚鹏","曾书雅","张安新","张佰俊","张二强","张俊棋","张涛","张小换","张扬","张洋","张元英","周冲冲","周更新"); 
function showName(){ 
    var index = Math.floor(Math.random()*names.length); 
    var name = names[index]; 
    document.getElementById("showView").innerHTML = name; 
    idd=setTimeout("showName()",50); 

var state = true; 
var idd; 
function sssss(){ 
    if(state){ 
        showName(); 
        state = false; 
    } 
    else{ 
        clearTimeout(idd); 
        state = true; 
    } 
         

 
 
</script> 
</head> 
 
<body> 
<div id="showView" style="width:200px; height:100px; font-size:14px; color:#09C;"></div> 
<input type="button" onclick="sssss()" value="state"/> 
</body> 
</html> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var names=new Array("蔡帅","常赛赛","陈晨","陈俊","陈磊","陈晓东","陈楠","杜广伟","段礼想","范晓峡","冯贺娟","高春发","高洋","葛阳","郭博","何素芳","何晓伟","胡军鹏","黄文春","惠媛佩","靳培强","李传允","李浩博","李俊锋","李乐乐","李品","李伟峰","李文博","李亚伟","李益芳","梁建","刘洪超","刘利丹","刘松松","罗凯凯","马王莹","苗珺杰","聂鹏英","秦仕朋","沈冬冬","石亚博","时宁","王高杨","王恒","王腾飞","王小洁","吴南","肖桦","杨琪琳","余洋","岳亚鹏","曾书雅","张安新","张佰俊","张二强","张俊棋","张涛","张小换","张扬","张洋","张元英","周冲冲","周更新");
function showName(){
 var index = Math.floor(Math.random()*names.length);
 var name = names[index];
 document.getElementById("showView").innerHTML = name;
 idd=setTimeout("showName()",50);
}
var state = true;
var idd;
function sssss(){
 if(state){
  showName();
  state = false;
 }
 else{
  clearTimeout(idd);
  state = true;
 }
  
}


</script>
</head>

<body>
<div id="showView" style="width:200px; height:100px; font-size:14px; color:#09C;"></div>
<input type="button" onclick="sssss()" value="state"/>
</body>
</html>

 

 

补充:web前端 , HTML/CSS  ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,