村長fb!
此乃舊版魚蛋村,訪客請【按此到新版魚蛋村】繼續瀏覽
魚蛋村 yudans語法區語法範例 → 計算生肖

計算生肖

  • Internet Explorer 6.0
  • Internet Explorer 7.0
  • Internet Explorer 8.0
  • Mozilla Firefox 2.0
  • Mozilla Firefox 3.0
  • Google Chrome
  • Safari 3.1
  • Opera 9.5
  • 語法介紹 Introduction:
  • 計算生肖 - 輸入年份便可計算當年的生肖。
  • 語法總長度:1015 字元
  • 範例 Example:
  • 請輸入年份: 當年的生肖是:
  • 請將以下程式碼貼到<body>與</body>之間:
<script type="text/javascript"><!--
function getpet() { 
var toyear = 1997; 
var birthyear = document.getElementById("inyear").value; 
x = (toyear - birthyear) % 12 
if ((x == 1) || (x == -11)) {birthpet="鼠"} 
else if (x == 0) {birthpet="牛"} 
else if ((x == 11) || (x == -1)) {birthpet="虎"} 
else if ((x == 10) || (x == -2)) {birthpet="兔"} 
else if ((x == 9) || (x == -3)) {birthpet="龍"} 
else if ((x == 8) || (x == -4)) {birthpet="蛇"} 
else if ((x == 7) || (x == -5)) {birthpet="馬"} 
else if ((x == 6) || (x == -6)) {birthpet="羊"} 
else if ((x == 5) || (x == -7)) {birthpet="猴"} 
else if ((x == 4) || (x == -8)) {birthpet="雞"} 
else if ((x == 3) || (x == -9)) {birthpet="狗"}
else if ((x == 2) || (x == -10)) {birthpet="豬"}
else {birthpet="輸入錯誤"}
document.getElementById("birth").innerHTML = birthpet;}
// --></script>
請輸入年份:<input type="text" size="5" id="inyear" />
<input type="button" value="計算" onclick="getpet()" />
當年的生肖是:<span id="birth"></span>
  • 可修改的地方 Modify:
  • 可修改第 21 至 23 行的文字
魚蛋村,語法,圖片,素材,下載,琴譜,字型,教學,網頁製作,網頁教學,表情符號,程式,yudan,yudans,yudan village,javascript,cgi,php,msn,css,html,w3c,teach
footer