【发布时间】:2014-08-03 16:37:29
【问题描述】:
首先,我不是很擅长 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" />
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>Spin the Wheel!</title>
</head>
<body>
<button name="generate" type="button" onClick="gennum()">Spin!</button>
<script>
function gennum() {
var result=Math.floor(Math.random()*101)
check()
}
function check() {
if (result > 0 && result < 11) {
alert("You win 1 free spin! Spin again!")
}
else if (result > 10 && result < 16) {
alert("You win 2 free spins! Spin again twice!")
}
else if (result > 15 && result < 26) {
alert("Sorry, you won nothing. Please try again tommorow.")
}
else if (result > 25 && result < 36) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('7L6XPaY8').value)
;
window.location.href = link;
}
else if (result > 35 && result < 45) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('NmE6B5uF').value)
;
window.location.href = link;
}
else if (result > 44 && result < 52) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('ZpLb9TRC').value)
;
window.location.href = link;
}
else if (result > 51 && result < 59) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('JQa6fGHH').value)
;
window.location.href = link;
}
else if (result > 58 && result < 64) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('rKjPGXak').value)
;
window.location.href = link;
}
else if (result > 63 && result < 69) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('5QQyCJaD').value)
;
window.location.href = link;
}
else if (result > 68 && result < 71) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('474zbnkE').value)
;
window.location.href = link;
}
else if (result > 70 && result < 74) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('QUjY2NSN').value)
;
window.location.href = link;
}
else if (result > 73 && result < 76) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('FNVYSHu5').value)
;
window.location.href = link;
}
else if (result > 75 && result < 100) {
alert("Sorry, you won nothing. Please try again tommorow.")
}
else if (result = 100) {
var link = "mailto:name@example.com"
+ "&subject=" + escape("Spinner")
+ "&body=" + escape(document.getElementById('uZ63V4me').value)
;
window.location.href = link;
}
}
</script>
</body>
</html>
这就是所有的代码。如果您知道它为什么不起作用,请回复。
【问题讨论】:
标签: javascript onclick spinner form-submit