※ 您是那個星期出生的 ※
|
<script language="JavaScript"> <!-- function MakeArray(n) { this.length = n; for (var i = 1; i <=n; i++) { this[i] = 0; } } days = new MakeArray(7); days[0] = "星期六" days[1] = "星期日" days[2] = "星期一" days[3] = "星期二" days[4] = "星期三" days[5] = "星期四" days[6] = "星期五" months = new MakeArray(12); months[1] = "一" months[2] = "二" months[3] = "三" months[4] = "四" months[5] = "五" months[6] = "六" months[7] = "七" months[8] = "八" months[9] = "九" months[10] = "十" months[11] = "十一" months[12] = "十二" function compute(form) { var val1 = parseInt(form.day.value, 10); if ((val1 < 0) || (val1 > 31)) { alert("好像沒這個日期耶!"); } var val2 = parseInt(form.month.value, 10); if ((val2 < 0) || (val2 > 12)) { alert("好像沒這個月份喔!"); } var val2x = parseInt(form.month.value, 10); var val3 = parseInt(form.year.value, 10)+1911; if (val3 < 1900) { alert("你真老耶!這位大伯!"); } if (val2 == 1) { val2x = 13; val3 = val3-1; } if (val2 == 2) { val2x = 14; val3 = val3-1; } var val4 = parseInt(((val2x+1)*3)/5, 10); var val5 = parseInt(val3/4, 10); var val6 = parseInt(val3/100, 10); var val7 = parseInt(val3/400, 10); var val8 = val1+(val2x*2)+val4+val3+val5-val6+val7+2; var val9 = parseInt(val8/7, 10); var val0 = val8-(val9*7); form.result1.value = "民國"+form.year.value+"年 "+months[val2]+"月 "+form.day.value +"日"; form.result2.value = days[val0]; } // --> </script> <body background="jpg/01_bkg1.jpg"> <div align="center"><center> <table border="1" cellspacing="1" width="400" bgcolor="#66CCFF"> <tr> <td valign="top"><form> <p>年 (民國):<input type="text" size="5" name="year"> </p> <p>月 (1-12):<input type="text" size="5" name="month"> </p> <p>日 (1-31):<input type="text" size="5" name="day"> </p> <p><input type="button" value=" 算 看 看 " onclick="compute(this.form)"> <input type="reset" value=" 清 除 "> </p> <p>你的生日是:<input type="text" size="18" name="result1"> </p> <p>你是星期?出生:<input type="text" size="18" name="result2"> </p> </form> <p><font color="#000000">誰會記得你星期幾出生的呀,算算看吧!</font></p> </td> </tr> </table> </center></div> |