html抽奖源码
㈠ 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添加几位,但是实际上你的存款还是不变的。
抽奖机会你在本地修改了,服务器那边也是没有的。