Calculate the number of days in a day or a week

Source: Internet
Author: User
Tip: you can modify some code before running

<html><head><title>Calculate the number of days in a day or a week</title><style type="text/css"><!--body { font-family: "宋体"; font-size: 9pt; margin-top: 0px; margin-left: 0px; margin-right: 0px}A { COLOR: black; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: none } A:hover { COLOR: red; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: underline }a:active { font: 9pt "宋体"; cursor: hand; color: #FF0033 }--></style><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body><br><br><center><font color=red face="隶书" size=6>Calculate the number of days in a day or a week</font></center><br><br><center><table border=0 bordercolor=blue borderlight=green cellpadding="0" cellspacing="0"><tr><td align=center><font size=4 color=red face="Arial, Helvetica, sans-serif"><strong>In the script display area</strong></font></td></tr><tr><td align=center><SCRIPT LANGUAGE="LiveScript"><!--function mod(x, x_div){ for (var i=x; i>=x_div; i -= x_div); return i;}function checkNum(str, min, max) { if (str == "") { alert("Enter a number in the field, please."); return false; } for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i + 1); if (ch < "0" || ch > "9") { alert("Try a number, please."); return false; } } var val = parseInt(str, 10); if ((val < min) || (val > max)) { alert("Try a number from 1 to "+max+"."); return false; } return true;}function pushbutton(form){ //Check for a valid date if ((checkNum(form.day.value,1,31)) && (checkNum(form.month.value,1,12)) && (checkNum(form.year.value,0,99))){ var cur_day = parseInt(form.day.value,10); var cur_month = parseInt(form.month.value,10); var cur_year = parseInt(form.year.value,10); //alert(" "+cur_day+" "+cur_month+" "+cur_year); //Significant value var sig_val; if (cur_month == 1) sig_val = 0; else if (cur_month == 2) sig_val = 3; else if (cur_month == 3) sig_val = 3; else if (cur_month == 4) sig_val = 6; else if (cur_month == 5) sig_val = 1; else if (cur_month == 6) sig_val = 4; else if (cur_month == 7) sig_val = 6; else if (cur_month == 8) sig_val = 2; else if (cur_month == 9) sig_val = 5; else if (cur_month == 10) sig_val = 0; else if (cur_month == 11) sig_val = 3; else if (cur_month == 12) sig_val = 5; var val1 = mod((cur_year + parseInt(cur_year/4) + cur_day + sig_val),7); //Display the correct file if (val1 == 0) alert("星期天"); else if (val1 == 1) alert("星期一"); else if (val1 == 2) alert("星期二"); else if (val1 == 3) alert("星期三"); else if (val1 == 4) alert("星期四"); else if (val1 == 5) alert("星期五"); else if (val1 == 6) alert("星期六"); return true; } else return false;}//--> </sCRIPT><FORM NAME = "What_Day"><B>:</b> <INPUT TYPE="num" name="day" onChange="if (!checkNum(this.value, 1, 31)){this.focus();this.select();} else {}" size=10 value=""> <br><B>Month:</b> <INPUT TYPE="num" name="month" onChange="if (!checkNum(this.value, 1, 12)){this.focus();this.select();} else {}" size=10 value=""><br><B>Year:</b> <INPUT TYPE="num" name="year" onChange="if (!checkNum(this.value, 0, 99)){this.focus();this.select();} else {}" size=10 value=""> <br><INPUT TYPE="button" name="Find_Out" value="算一下吧!" onclick="pushbutton(this.form)"></fORM></td></tr></table></center><br><br><center> <SCRIPT LANGUAGE="JavaScript"><!-- hidefunction goHist(a) { history.go(a);}//--></script></center><br><br></body></html>
Tip: you can modify some code before running

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.