Using the JS scripting language to implement a request a date is the day of the year, consider the run-year
We need to enter the date in the page popup, the code is as follows:
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<body>
<!--
Calculate by switch structure A date is the day of the year, consider the year
-
<script type= "Text/javascript" >
var y =parseint (Prompt ("Please enter the Year");
var m = parseint (Prompt ("Please enter Month"));
var d =parseint (Prompt ("Please enter the number");
var sum = 0
Switch (m-1) {
Case 11:
sum + = 30;
Case 10:
sum + = 31;
Case 9:
sum + = 30;
Case 8:
sum + = 31;
Case 7:
sum + = 31;
Case 6:
sum + = 30;
Case 5:
sum + = 31;
Case 4:
sum + = 30;
Case 3:
sum + = 31;
Case 2:
if ((y% 4 = = 0 && y% 100! = 0) | | (y% 400 = = 0)) {
sum + = 29;
}
else{
sum + = 28;
}
Case 1:
sum + = 31;
sum + = D;
Break
Default:
sum = d
}
alert (sum)
</script>
</body>
The results are as follows:
Using the JS scripting language switch to implement a request a date is the day of the year, consider the run-year