javascript基礎-搶購器與雙色球模擬搖獎器

手機搶購器

<!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>
	    var time;
		var secondsum;
     	function limitsale(){
			var hours=document.getElementById("hour");
			var minutes=document.getElementById("minute");
			var seconds=document.getElementById("second");
			secondsum++;
			if(seconds.value==0){
				seconds.value=60;
				minutes.value=parseInt(minutes.value)-1;
				}
				seconds.value=parseInt(seconds.value)-1;
				if(secondsum%3600==0){
					hours.value=parseInt(hours.value)-1;
					seconds.value=60;
					minutes.value=59;
					}
					if(hours.value==0){
						if(minutes.value==0){
							if(seconds.value==0){
								window.clearInterval(time);
								}
							}
						}
		}
		time=window.setInterval("limitsale()",1000);	
     </script>
</head>

<body bgcolor="#000000" onload="limitsale()">
	<br /><br /><br /><br /><br />
    <center>
    <img src="iPhone.jpg" style="width:300px;height:300px" />
    &nbsp;&nbsp;&nbsp;
    <input type="text" value="0" id="hour" style="width:30px;height:30px"/>
    <font color="#FFFFFF">小時</font>
    <input type="text" value="2" id="minute" style="width:30px;height:30px"/>
    <font color="#FFFFFF">分鐘</font>
    <input type="text" value="0" id="second" style="width:30px;height:30px"/>
    <font color="#FFFFFF">秒</font>
    </center>
</body>
</html>

wKiom1cynJmD54owAAGqu3Fj6gc395.png

雙色球模擬搖獎器

<!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 language="javascript">
	var number=0;
	var timer;
	function time(){
		var numr1=document.getElementById("randomnumr1");
		var numr2=document.getElementById("randomnumr2");
		var numr3=document.getElementById("randomnumr3");
		var numr4=document.getElementById("randomnumr4");
		var numr5=document.getElementById("randomnumr5");
		var numr6=document.getElementById("randomnumr6");
		var numb=document.getElementById("randomnumb");
		var num=document.getElementById("randomnum");
		number++;
		if(number<=30){
			num.value=Math.floor(Math.random()*33+1);//1-33  ;
			if(number==5){
				 numr1.value=num.value;
				}if(number==10){
					numr2.value=num.value;
					}if(number==15){
						numr3.value=num.value;
						}if(number==20){
							numr4.value=num.value;
							}if(number==25){
								numr5.value=num.value;
								}if(number==30){
									numr6.value=num.value;
									}
		}
		else if(number>30){
			num.value=Math.floor(Math.random()*16+1);//1-16
			if(number==35){
				numb.value=num.value;
				ownstop();
				}
		}
		}
		function ownstart(){
			var numr1=document.getElementById("randomnumr1");
			var numr2=document.getElementById("randomnumr2");
			var numr3=document.getElementById("randomnumr3");
			var numr4=document.getElementById("randomnumr4");
			var numr5=document.getElementById("randomnumr5");
			var numr6=document.getElementById("randomnumr6");
			var numb=document.getElementById("randomnumb");
			var num=document.getElementById("randomnum");
			numr1.value="";
			numr2.value="";
			numr3.value="";
			numr4.value="";
			numr5.value="";
			numr6.value="";
			numb.value="";
			num.value="";
			number=0;
			timer=window.setInterval("time()",1000);
			}
		function ownstop(){
		   window.clearInterval(timer);
		}
    </script>
</head>

<body style="background:url(雙色球.jpg) no-repeat; background-position:top; background-size:cover">
    <center>
        <br /><br /><br /><br />
        <input type="text" style="width:30px;height:30px;color:#F00" id="randomnumr1" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="text" style="width:30px;height:30px;color:#F00; alignment-adjust:central" id="randomnumr2" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="text" style="width:30px;height:30px;color:#F00" id="randomnumr3" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="text" style="width:30px;height:30px;color:#F00" id="randomnumr4" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="text" style="width:30px;height:30px;color:#F00"id="randomnumr5" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="text" style="width:30px;height:30px;color:#F00" id="randomnumr6" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="text" style="width:30px;height:30px;color:#00F"id="randomnumb" />
        <br /><br /><br /><br />
        <input type="text" style="width:30px;height:30px"id="randomnum"/><br /><br>
        <input type="button" value="開始搖獎" onclick="ownstart()" />
    </center>
</body>
</html>

wKiom1cynUSCFKBOAANOLvLyI00459.png

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章