Source code var win = null; var month = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); function $(id) { return document.getElementById(id); } function displayCal() { var f = $('frm1'); if (win == null || win.closed) { win = window.open("", "cal", "width=320,height=280"); } var days = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); var ctr; for (ctr=0; ctr<12; ctr++) { if (f.lstMonth[ctr].selected) break; } var dx = new Date(); if (ctr >= 12) ctr = dx.getMonth(); if (f.yr.value < 1900 || f.yr.value > 3999) f.yr.value = dx.getFullYear(); var d0 = new Date(f.yr.value, ctr, 1); var dx = new Date(d0.getFullYear(), ctr, 1); win.document.writeln(''); win.document.writeln('' + month[d0.getMonth()] + ' ' + d0.getFullYear() + ''); win.document.write(''); for (ctr=0; ctr<7; ctr++) { win.document.write('' + days[ctr] + ''); } win.document.writeln(''); ctr = d0.getDay(); if (ctr > 0) { win.document.write(''); while (ctr-- > 0) { win.document.write(' '); } } while (d0.getMonth() == dx.getMonth()) { if (d0.getDay() == 0) { win.document.write(''); } var d = d0.getDate(); win.document.write('' + d + ''); if (d0.getDay() == 6) { win.document.writeln(''); } d0.setDate(d0.getDate() + 1); } if (d0.getDay() != 0) { ctr = 7 - d0.getDay(); while (ctr-- > 0) { win.document.write(' '); } win.document.writeln(''); } win.document.writeln(''); win.document.close(); return false; } function init() { $("frm1").onsubmit = function() { return false; } $("submitButton").onclick = displayCal; var d = new Date(); for (var i=0; i<12; i++) $("lstMonth").options[i] = new Option(month[i]); $("lstMonth").selectedIndex = d.getMonth(); $("yr").value = d.getFullYear(); } window.onload = init;