Crear un calendario

Buenas señores hoy les traigo como hacer un
 calendario sencillo con javascript.
 
 Aquí tienen el codigo.
 
 
<html>
<head>
<title></title>
</head>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var week = new Array("Do", "Lu", "Ma", "Mi", 
"Ju", "Vi", "Sá");
var monthdays = new Array(31, 28, 31, 30,
31, 30, 31, 31, 30, 31, 30, 31);
var today = new Date();
var month = today.getMonth();
var day = today.getDay();
var dayN = today.getDate();
var days = monthdays[month];
 
if (month >0) {
var year = today.getYear();
if (year%4 == 0) days = 29;
	}
 
document.write("Calendario " + year);
document.write("<table border='1' cellspacing='0' 
 cellpadding='0'>");
document.write("<tr>");
 
for (var i=0; i<7; i++) {
document.write("<td width='30' height='30'>");
document.write("<div align='center'>");
document.write(" " + week[i] + "</div>");
document.write("</td>");
}
 
document.write("</tr>");
 
var jumped = 0;
var inserted = 1;
var start = day - dayN%7 + 1;
if (start < 0) start += 7;
var weeks = parseInt((start + days)/7);
 
if ((start + days)%7 != 0) weeks++;
 
for (var i=weeks; i>0; i--) {
document.write("<tr>");
for (var j=7; j>0; j--) {
document.write("<td>");
if (jumped<start || inserted>days) {
document.write("<div align='center'></div>");
jumped++;
}
else {
if (inserted == dayN) document.write("<div align='center'>
 [" + inserted + "]</div>");
else document.write("<div align='center'>" + inserted
+ "</div>");
inserted++;
}
document.write("</td>")
 }
 document.write("</tr>");
}
document.write("</table>");
</script>
</body>
</html>

Share this

Related Posts

Previous
Next Post »