標題:
練習九、互動式占卜小程式
[打印本頁]
作者:
游東祥
時間:
2014-7-18 16:11
標題:
練習九、互動式占卜小程式
本帖最後由 游東祥 於 2014-7-18 16:33 編輯
互動式占卜小程式
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
年:<input id="iyear" /><br />
月:<input id="imonth" /><br />
日:<input id="iday" /><br />
<button onclick="calc();">True Hard</button>
<div id="result">請輸入出生年月日。</div>
<script type="text/javascript">
function inputRange(msg,min,max) {
var value = parseInt(prompt(msg));
return Math.min(max, Math.max(min, value));
}
function calc() {
var y = parseInt(document.getElementById("iyear").value);
var m = parseInt(document.getElementById("imonth").value);
var d = parseInt(document.getElementById("iday").value);
var r = ((y + m) * d) % 3;
var a = ["吉", "一般", "凶"];
var rHTML = "您輸入的日期是:" + y + "/" + m + "/" + d + "<br />" +
"您的運勢是:" + a[r];
document.getElementById("result").innerHTML = rHTML;
}
</script>
</body>
</html>
複製代碼
作者:
李允軒
時間:
2014-7-18 16:14
<!DOCTYPE html>
<html>
<head>
<meta charset "UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
年:<input id="iyear" /><br />
月:<input id="imonth" /><br />
日:<input id="iday" /><br />
<button onclick="calc();">按鈕</button>
<div id = "result">請輸入出生年月日。</div>
<script type="text/javascript">
function inputRange(msg,min,max) {
var value = parseInt(prompt(msg));
return Math.min(max,Math.max(min,value));
}
function calc () {
var y = parseInt(document.getElementById("iyear").value);
var m = parseInt(document.getElementById("imonth").value);
var d = parseInt(document.getElementById("iday").value);
var r = ((y + m) * d) % 3;
var a = ["吉", "一般", "凶"];
document.getElementById("result").innerHTML = "您輸入的日期是:" + y + "/" + m + "/" + d + "<br />" + "您的運勢是:" + a[r];
}
</script>
</body>
</html>
複製代碼
作者:
張彥承
時間:
2014-7-18 16:14
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
年:<input id="iyear"/><br />
月:<input id="imonth"/><br />
日:<input id="iday"/><br />
<button onclick="calc();">Super Power Beat Down</button>
<div id="result"></div>
<script type="text/javascript">
function inputRange(msg,min,max) {
var value = parseInt(prompt(msg));
return Math.min(max,Math.max(min,value));
}
function calc(){
var y= parseInt(document.getElementById("iyear").value);
var m= parseInt(document.getElementById("imonth").value);
var d= parseInt(document.getElementById("iday").value);
var r = ((y + m) * d) % 3;
var a = ["吉", "一般", "凶"]
document.getElementById("result").innerHTML="您輸入的日期是:" + y + "/" + m + "/" + d+
"<br />"+"您的運勢是:"+a[r];
}
</script>
</body>
</html>
複製代碼
作者:
陳品諨
時間:
2014-7-18 16:15
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
年:<input id="iyear"/><br/>
月:<input id="imouth"/><br/>
日:<input id="day"/><br/>
<button onclick="alert('kdhjsbuxbeycbduvfufd'pg[sj">請按</button>
<div id="resalt"></div>
<script type="text/javascript">
function calc () {
var y =document. getElementById("iyear").value
var m =document. getElementById("imouth").value
var d =document. getElementById("iday").value
document.getElementById("resalt").innerHTML=y+"|"+m"|"+d+"</br>"+
您的運勢是:+a[r])
}
</script>
</body>
</html>
複製代碼
作者:
劉泳鱔
時間:
2014-7-18 16:24
<!DOCTYPE htyml>
<html>
<head>
<meta charset="UTF-8">
<title>我的占卜程式</title>
</head>
<body>
年: <input id="iyear" /><br/>
月: <input id="imonth" /><br/>
日: <input id="iday" /><br/>
<button onclick="calc();">啊~~只要呼吸就好</button>
<div id="result"></div>
<script type="text/javascript">
function calc()
{
alert("calc");
}
function calc()
{
var y=parseInt(document.getElementById("iyear").value);
var m=parseInt(document.getElementById("imonth").value);
var d=parseInt(document.getElementById("iday").value)
var r=((y+m)*d)%3
var a=["吉","一般","凶"]
document.getElementById("result").innerHTML="您輸入的日期是:"+y"/"+m"/"+d+"br<>"+"您的運勢是: "+a[r];
}
/*
var y=parseInt(prompt("請輸入出生年"));
var isLeapYear=false;
if(y%400==0)
var m=parseInt(prompt("請輸入出生月"));
{
isLeapYear=true;
}else if(y%4==100 && y%100!=0)
{
isLeapYear=true;
}
var maxDays=[31,28,31,30,31,30,31,31,30,31,30,31];
maxDays[1]=(isLeapYear)?29:28;
var d=parseInt(prompt("請輸入出生日"));
alert("你的出生日期是: "+y+"/"+m+"/"+d+maxDays[m-1]);
var result=((y+m)*d)%3;
if(result==0)
{
alert("吉");
}else if(result==1)
{
alert("一般");
}else
{
alert("凶");
}
</script>
</body>
</html>
複製代碼
作者:
李允軒
時間:
2014-7-18 16:31
本帖最後由 李允軒 於 2014-7-21 13:55 編輯
<!DOCTYPE html>
<html>
<head>
<meta charset "UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
年:<input id="iyear" /><br />
月:<input id="imonth" /><br />
日:<input id="iday" /><br />
<button onclick="calc();">按鈕</button>
<div id = "result">請輸入出生年月日。</div>
<script type="text/javascript">
function inputRange(value,min,max) {
return Math.min(max,Math.max(min,value));
}
function calc () {
var y = inputRange(parseInt(document.getElementById("iyear").value), 1900, 2014);
var m = inputRange(parseInt(document.getElementById("imonth").value),1, 12);
var isLeapYear = false;
if(y % 400 == 0) || (y % 4 == 0 && y % 100 != 0)
{
isLeapYear = true;
}
var maxdays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
maxdays[1] = (isLeapYear)? 29 : 28;
var d = inputRange(parseInt(document.getElementById("iday").value),1, maxdays[m - 1]);
var r = ((y + m) * d) % 3;
var a = ["吉", "一般", "凶"];
document.getElementById("result").innerHTML = "您輸入的日期是:" + y + "/" + m + "/" + d + "<br />" + "您的運勢是:" + a[r] ;
document.getElementById("iyear").value = y;
document.getElementById("imonth").value = m;
document.getElementById("iday").value = d;
}
</script>
</body>
</html>
複製代碼
作者:
張彥承
時間:
2014-7-21 13:55
<!DOCTYPE html>
<html>
<head>
<meta charset "UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
年:<input id="iyear" /><br />
月:<input id="imonth" /><br />
日:<input id="iday" /><br />
<button onclick="calc();">按鈕</button>
<div id = "result">請輸入出生年月日。</div>
<script type="text/javascript">
function inputRange(msg,min,max) {
var value = parseInt(prompt(msg));
return Math.min(max,Math.max(min,value));
}
function calc () {
var y = parseInt(document.getElementById("iyear").value);
var m = parseInt(document.getElementById("imonth").value);
var d = parseInt(document.getElementById("iday").value);
var r = ((y + m) * d) % 3;
var a = ["吉", "一般", "凶"];
document.getElementById("result").innerHTML = "您輸入的日期是:" + y + "/" + m + "/" + d + "<br />" + "您的運勢是:" + a[r];
}
</script>
</body>
</html>
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2