•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 375,229 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,264 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 478 | Replies: 1 | Solved
![]() |
•
•
Join Date: Apr 2008
Posts: 29
Reputation:
Rep Power: 1
Solved Threads: 0
this is what i am trying to do.
Write a simple program that do the following:
1. Accept user input for date in format of (YYYY-MM-DD).
2. Validate YYYY, MM, DD are number.
3. Validate whether this input is a valid date.
4. Print a monthly calendar for the month of the input.
here is my code
Why it still cant display
?
Write a simple program that do the following:
1. Accept user input for date in format of (YYYY-MM-DD).
2. Validate YYYY, MM, DD are number.
3. Validate whether this input is a valid date.
4. Print a monthly calendar for the month of the input.
here is my code
<html>
<head>
<title>Calender</title>
</head>
<body>
<table border="1" align=center>
<script type="text/javascript">
var Max_day=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var Max_day=[31,28,31,30,31,30,31,31,30,31,30,31];
var d=new Array(January,February,March,April,May,June,July,August,September,October,November,December);
var d=[January,February,March,April,May,June,July,August,September,October,November,December];
var date=new Date();
var user;
var input=Array();
var true=0;
var day=1;
do
{
user=Number(prompt("Please insert a date yyyy-mm-dd:"));
input=user.split("-");
if(input[0]%4==0)
Max_day[1]=29;
if(input[0]<1 || input[0]>9999 || isNaN(input[0]))
document.write("Error <br>");
else if(input[1]<1 || input[1]>12 || isNaN(input[1]))
document.write("Error <br>");
else if(input[2]<1 || input[2]>Max_day || isNaN(input[2]))
document.write("Error <br>");
else
true=1;
}
while(true==0)
date.setFullYear(input[0]);
date.setMonth(input[1]-1);
document.write("<tr>"+date.getFullYear()+" "+d[date.getMonth()]+"</tr>");
document.write("<tr><td>Sunday</td><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td><td>Saturday</td></tr>");
for(var s=0; s<=7; s++)
{
document.write("<tr>");
for(var i=0; i<=6; i++)
{
date.setDate(day);
if(date.getDay()==x)
{
document.write("<td>"+day+"</td>");
day++;
}
else
document.write("<td></td>");
if(Max_day[input[1]-1<day)
break;
}
document.write("</tr>");
}
</script>
</table>
</body>
</html>
?
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: write xy coords
- Next Thread: validation for dynamic multiple text fields


Linear Mode