當前位置:首頁 » 操作系統 » html抽獎源碼

html抽獎源碼

發布時間: 2022-12-23 07:58:02

㈠ html下怎麼實現轉盤式抽獎(每個獎品塊按順序亮滅,頻率越來越慢,最後停在最終獎品)而不是突然停,

思路:1.用h5技術,將每個獎品塊的顏色默認顏色為暗色;2.指針到達的獎品塊,將顏色調明,指針離開獎品塊,則回復默認顏色;3.用自定義動畫控制頻率。

㈡ 如何使用javascript做一個簡單的抽獎程序

參考下面寫的小程序,是一個跑馬燈效果。
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>抽獎</title>
<style>
*{margin:0;padding:0;}
#box{width:400px;height:400px;border:2px #C6C solid;margin:20px auto;background:#99F;}
#box>div{position:absolute;width:60px;height:40px;color:#F03;font-size:20px;border:2px #F63 solid;opacity:0.4;line-height:40px;background:#F96;}
#butt{position:absolute;background:#F6C;color:#36F;font-size:16px;margin-top:200px;margin-left:150px;}
#span{width:300px;height:40px;margin-left:160px;display:block;border:2px #F63 solid;float:left;line-height:40px;}
#span i{font-style:normal;}
</style>
</head>
<body>
<span id="span">離抽獎結束還有:<i></i><i></i><i></i><i></i></span>
<div id="box" class="box">
<div>一等獎</div>
<div style="margin-left:336px">二等獎</div>
<div style="margin-left:336px;margin-top:356px;">三等獎</div>
<div style="margin-top:356px;">安慰獎</div>
<button id="butt" onclick="butt()">點擊抽獎</button>
</div>
<script type="text/javascript">
var opa=document.getElementById("box").getElementsByTagName("div");
var ii=document.getElementById("span").getElementsByTagName("i");
for(var i=0;i<opa.length;i++){
opa[i].style.opacity=0.4;
}
//var span=document.getElementById("span").style;
var i=0,
t,tt,r,
count1=1,//限制一等獎只中一次,當一等獎抽完後順延到二等獎
count2=3,//限制二等獎只中3次,當二等獎抽完後順延到三等獎
count3=10,//限制等獎只中10次
prize=1,//抽獎是否結束
time=200,
curr=0;//每次抽獎完成才能再次點擊
var toDate = new Date(2016,7,29,19,55,0);
var dt,currDate;
function obtain(){//倒計時
currDate=new Date();
dt=Math.ceil((toDate.getTime()-currDate.getTime())/1000);<!--轉換成s-->
ii[0].innerHTML=parseInt(dt/(24*60*60))+'天';
ii[1].innerHTML=Math.floor(dt%(24*60*60)/(60*60))+'時';
ii[2].innerHTML=Math.floor(dt%(24*60*60)%(60*60)/60)+'分';
ii[3].innerHTML=Math.floor(dt%60)+'秒';
if(dt<=0){
prize=0;
ii[0].innerHTML=0+'天';ii[1].innerHTML=0+'時';ii[2].innerHTML=0+'分';ii[3].innerHTML=0+'秒';
if(prize==0&&s==0){alert("抽獎已結束");clearInterval(tt);}

}
}
tt=setInterval(obtain,1000);
function butt(){
curr++;
if(count1==0&&count2==0&&count3==0){
prize=0;
}
if(curr==1&&prize==1){
if(i!=0){
opa[i].style.opacity=0.4;
}
i=0;
clearInterval(t);
r=parseInt(Math.random()*10000)+1;//產生1-10000的隨機數
//r=1;
opa[i].style.opacity=1;
t=setInterval(move,time);
}else if(curr!=1&&prize==1){alert("請等待本次抽獎完成再抽獎");alert("請點擊確定繼續");}
else if(prize==0){alert("抽獎已結束");}
}
/*function move(r){
switch(r){
case 1:
}
}*/
function move(){

opa[i].style.opacity=0.4;
if(i<opa.length-1){
i++;
}else{i=0;}
opa[i].style.opacity=1;
time+=50;
console.log("r="+r+","+"time="+time);
if(r==1&&count1>0){//中一等獎
clearInterval(t);
t=setInterval(move,time);
if(time==800){
clearInterval(t);
time=200;
count1--;
curr=0;
console.log("中一等獎的次數還有:"+count1+"次");
}
}else if((r%2999==0||r==1&&count1==0)&&count2>0){//中二等獎
clearInterval(t);
t=setInterval(move,time);
if(time==850){
count2--;
clearInterval(t);
time=200;
curr=0;
console.log("中二等獎的次數還有:"+count2+"次");
}
}else if((r%1000==0||r%2999==0&&count2==0||r==1&&count1==0)&&count3>0){//中三等獎
clearInterval(t);
t=setInterval(move,time);
if(time==900){
time=200;
count3--;
clearInterval(t);
curr=0;
console.log("中三等獎的次數還有:"+count3+"次");
}
}else{//安慰獎
clearInterval(t);
t=setInterval(move,time);
if(time==950){
clearInterval(t);
curr=0;
time=200;
}
}
}
</script>

</body>
</html>

㈢ HTML源代碼是什麼

網頁空白處點擊右鍵
查看源文件
那就是HTML代碼
用處就是以瀏覽器認識的格式
來布局網頁
這里包括圖片載入
文字樣式等等信息
你看到的東西應該在HTML里都能找到

㈣ 用html5+js 做一個轉盤抽獎怎麼做,求源碼

5分給你個程序。。。
自己參考改吧

<input type="button" value="開始旋轉" onclick="spin();" style="float: left;" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

<canvas id="wheelcanvas" width="500" height="500"></canvas>
<script type="application/javascript">
var colors = ["#B8D430", "#3AB745", "#029990", "#3501CB",
"#2E2C75", "#673A7E", "#CC0071", "#F80120",
"#F35B20", "#FB9A00", "#FFCC00", "#FEF200"];
var restaraunts = ["北京", "上海", "天津", "南京",
"杭州", "深圳", "武漢", "濟南",
"重慶", "大連", "合肥", "鄭洲"];

var startAngle = 0;
var arc = Math.PI / 6;
var spinTimeout = null;

var spinArcStart = 10;
var spinTime = 0;
var spinTimeTotal = 0;

var ctx;

function draw() {
drawRouletteWheel();
}

function drawRouletteWheel() {
var canvas = document.getElementById("wheelcanvas");
if (canvas.getContext) {
var outsideRadius = 200;
var textRadius = 160;
var insideRadius = 125;

ctx = canvas.getContext("2d");
ctx.clearRect(0,0,500,500);

ctx.strokeStyle = "black";
ctx.lineWidth = 2;

ctx.font = 'bold 12px sans-serif';

for(var i = 0; i < 12; i++) {
var angle = startAngle + i * arc;
ctx.fillStyle = colors[i];

ctx.beginPath();
ctx.arc(250, 250, outsideRadius, angle, angle + arc, false);
ctx.arc(250, 250, insideRadius, angle + arc, angle, true);
ctx.stroke();
ctx.fill();

ctx.save();
ctx.shadowOffsetX = -1;
ctx.shadowOffsetY = -1;
ctx.shadowBlur = 0;
ctx.shadowColor = "rgb(220,220,220)";
ctx.fillStyle = "black";
ctx.translate(250 + Math.cos(angle + arc / 2) * textRadius, 250 + Math.sin(angle + arc / 2) * textRadius);
ctx.rotate(angle + arc / 2 + Math.PI / 2);
var text = restaraunts[i];
ctx.fillText(text, -ctx.measureText(text).width / 2, 0);
ctx.restore();
}

//Arrow
ctx.fillStyle = "black";
ctx.beginPath();
ctx.moveTo(250 - 4, 250 - (outsideRadius + 5));
ctx.lineTo(250 + 4, 250 - (outsideRadius + 5));
ctx.lineTo(250 + 4, 250 - (outsideRadius - 5));
ctx.lineTo(250 + 9, 250 - (outsideRadius - 5));
ctx.lineTo(250 + 0, 250 - (outsideRadius - 13));
ctx.lineTo(250 - 9, 250 - (outsideRadius - 5));
ctx.lineTo(250 - 4, 250 - (outsideRadius - 5));
ctx.lineTo(250 - 4, 250 - (outsideRadius + 5));
ctx.fill();
}
}

function spin() {
spinAngleStart = Math.random() * 10 + 10;
spinTime = 0;
spinTimeTotal = Math.random() * 3 + 4 * 1000;
rotateWheel();
}

function rotateWheel() {
spinTime += 30;
if(spinTime >= spinTimeTotal) {
stopRotateWheel();
return;
}
var spinAngle = spinAngleStart - easeOut(spinTime, 0, spinAngleStart, spinTimeTotal);
startAngle += (spinAngle * Math.PI / 180);
drawRouletteWheel();
spinTimeout = setTimeout('rotateWheel()', 30);
}

function stopRotateWheel() {
clearTimeout(spinTimeout);
var degrees = startAngle * 180 / Math.PI + 90;
var arcd = arc * 180 / Math.PI;
var index = Math.floor((360 - degrees % 360) / arcd);
ctx.save();
ctx.font = 'bold 30px sans-serif';
var text = restaraunts[index]
ctx.fillText(text, 250 - ctx.measureText(text).width / 2, 250 + 10);
ctx.restore();
}

function easeOut(t, b, c, d) {
var ts = (t/=d)*t;
var tc = ts*t;
return b+c*(tc + -3*ts + 3*t);
}

draw();
</script>

㈤ html隨機抽取圖片,不重復抽取怎麼實現

這個很簡單
做一個array內含圖片數量個位置
var arr = [false,false,false,false,false,false,false];
寫一個函數reset,判斷是否全部圖片顯示過一遍,是則重置,讓圖片重新顯示一遍
function reset(){
var alltrue = true;
for(var i=0;i<arr.length;i++){
if(!arr[i]) alltrue = false;
}
if(alltrue) arr = [false,false,false,false,false,false,false];
}
然後每次隨機一個x0-6的數字x,判斷arr[x] true則重新隨機,false 則顯示圖片,更新arr[x]為true,檢查reset重置
就可以了

㈥ 怎麼用HTML做一個簡單的抽獎界面

河南新華專注互聯網教育san十二年 到校參觀 路費報銷 免費試聽課程!!

㈦ html頁面的倒計時代碼。。。。急求!!!!

<body>
<div id="timer"></div>
<script type="text/javascript" language="javascript">
var endDate=new Date(2010,11,11,17,05,40);//年月日時分秒,月要減去1
(function JiShi()
{
var now=new Date();
var oft=Math.round((endDate-now)/1000);
var ofd=parseInt(oft/3600/24);
var ofh=parseInt((oft%(3600*24))/3600);
var ofm=parseInt((oft%3600)/60);
var ofs=oft%60;
document.getElementById('timer').innerHTML='還有 '+ofd+' 天 ' +ofh+ ' 小時 ' +ofm+ ' 分鍾 ' +ofs+ ' 秒';
if(ofs<0){document.getElementById('timer').innerHTML='倒計時結束!';return;};
setTimeout('JiShi()',1000);
}());

</script>
</body>

㈧ 跪求html簡潔投票系統源碼,我已經在網上找了6天了,腦殼青痛!

六天,看來你夠苦的.幫你一下,用application做的,不知你是否滿意,
首先在你網站根目錄下新建一個名為:Global.asa的文件,然後把下列代碼貼上去:
<script language="vbscript" runat="server">
Sub Application_OnStart
application("yes")=0
application("no")=0
End Sub
</script>

然後再建一個投票的ASP文件,內容:
<style type="text/css">
<!--
.Vote {
height: 15px;
width: 200px;
border: 1px solid #0033FF;
}
#cYes {
background-color: #FF6600;
height: 15px;
width: 100px;
}
#cNo {
background-color: #FF6600;
height: 15px;
width: 100px;
}
-->
</style>
<form action="" method="post">
做一個投票系統難嗎?<br />
<input name="yes" type="radio" value="yes" onclick="if (this.checked==true) no.checked=false;" />贊成<br />
<input name="no" type="radio" value="no" onclick="if (this.checked==true) yes.checked=false;"/>反對<br />
<input name="投票" type="submit" value="投票" />
</form>
<%
nyes=0
nNo=0
'如果想重新計票,用下面四行
'application.lock()
'application("yes")=application("yes")+1
'application("no")=application("no")+1
'application.unlock()

count=application("yes")+application("no")
if count<>0 then
nyes=int(application("yes")*200/count)
nNo=int(application("no")*200/count)
end if

sYes=Request.form("yes")
sNo=Request.form("no")
act= Request.form("投票")
if act="投票" Then
if sYes="yes" Then
application.lock()
application("yes")=application("yes")+1
application.unlock()
Else
if sNo="no" then
application.lock()
application("no")=application("no")+1
application.unlock()
end if
End if
'圖形化顯示投票結果
count=application("yes")+application("no")
if count<>0 then
nyes=int(application("yes")*200/count)
nNo=int(application("no")*200/count)
end if
end if
%>

贊成:<%=application("yes")%>票
<div class="Vote" ><div ID="cYes" neme="cYes" style="width:<%=nyes%>px;"></div></div>
反對::<%=application("no")%>票
<div class="Vote" ><div ID="cNo" neme="cNo" style="width:<%=nNo%>px;"></div></div>

㈨ 我用javascript在html上做了抽獎網頁,抽獎已經實現了.我怎麼實現抽過人員不再被抽中.

新建一個數組,把抽獎的人放進數組中去,每抽一次就進這個數組中找一遍。

㈩ 求網頁抽獎修改抽獎機會代碼!!!

這個是在人家伺服器上的,你在本地修改是沒用的,
就打個比方,你把你存摺的金額PS添加幾位,但是實際上你的存款還是不變的。
抽獎機會你在本地修改了,伺服器那邊也是沒有的。

熱點內容
舒聽瀾卓禹安書名叫什麼 發布:2025-05-11 12:36:44 瀏覽:266
java開發web應用 發布:2025-05-11 12:35:51 瀏覽:694
鯊魚影視怎麼緩存電視 發布:2025-05-11 12:35:48 瀏覽:548
ios小項目源碼 發布:2025-05-11 12:35:47 瀏覽:754
為什麼打開的三菱程序不能編譯 發布:2025-05-11 12:16:40 瀏覽:21
ftp定價是怎麼回事 發布:2025-05-11 12:09:18 瀏覽:334
android敏捷開發 發布:2025-05-11 11:56:49 瀏覽:80
腳本pon 發布:2025-05-11 11:52:27 瀏覽:826
ct5推薦哪個配置 發布:2025-05-11 11:47:45 瀏覽:742
領購未上傳發票 發布:2025-05-11 11:43:27 瀏覽:717