This is a discussion on "Calendar Display" within the JavaScript Forum section. This forum, and the thread "Calendar Display are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Calendar Display
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Help! Need to format that calendar so it is consistent even when # of weeks do not match from one month to another. I have attached the code as well as the image of the discrepant months. Thank you.
|
|
|
|
#2
|
|||
|
|||
|
Addendum - actual code to generate calendar:
function generateCalendar(aord, cal, month, year, formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr, language, locale, callBackFn, action) { var today = new Date(); calendar = "" calendar +=" <table class=\"calendarTable\" cellspacing=0 cellpadding=2>" calendar +="<tr valign=top>" var mthIdx = month; var endday = getDaysInMonth(mthIdx, year) var changingmonth=mthIdx; var index = (mthIdx-1) var goPrevMonth = prevMonth(mthIdx) var goNextMonth = nextMonth(mthIdx) var nextYear = changeYear ('next', parseInt (month, 10), parseInt (year, 10)) var prevYear = changeYear ('prev', parseInt (month, 10), parseInt (year, 10)) // Create the calendar header var inventoryYr = new Date().getFullYear(); if (InventoryDate.getFullYear() != null) { inventoryYr = InventoryDate.getFullYear(); } if (prevYear >= today.getFullYear()) { calendar +=" <td colspan=1 align=left class=\"calend34\">" if(cal=="cal1"){ calendar +=" <a href='javascript:generateCalendar(\""+aord+ "\", \"" + cal + "\", " + goPrevMonth + "," + prevYear + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" calendar += dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\",\"premo\")'>" calendar += "<u class=\"calend34\"><</u> </a>" } calendar +=" </td>" } else { calendar +=" <td colspan=1 align=left class=\"calend34\">" if(cal=="cal1"){ calendar +=" <a style='text-decoration: none' 'javascript:generateCalendar(\""+aord+ "\", \"" + cal + "\", " + goPrevMonth + "," + prevYear + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" calendar += dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\",\"premo\")'><u class=\"calend34\"><</u></a>" } calendar +=" </td>" } calendar +=" <td colspan=5 align=center class=\"calend34\">" calendar += getMonth (mthIdx) + " " + year calendar +=" </td>" if (nextYear <= inventoryYr) { calendar +=" <td colspan=1 align=right class=\"calend34\">" if(cal=="cal2"){ calendar +="<a href='javascript:generateCalendar(\""+aord+ "\", \"" + cal + "\", " + goNextMonth + "," + nextYear + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" calendar += dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\",\"nextmo\")'><u class=\"calend34\">></u></a>" } calendar += "</td></tr>" }else { calendar +=" <td colspan=1 align=right class=\"calend34\">" if(cal=="cal2"){ calendar +="<a style='text-decoration: none' 'javascript:generateCalendar(\""+aord+ "\", \"" + cal + "\", " + goNextMonth + "," + nextYear + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" calendar += dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\",\"nextmo\")'><u class=\"calend34\">></u></a>" } calendar += "</td></tr>" } calendar +=" </tr><tr>" calendar +=" <td align=center width=\"14%\" class=\"daytitle\">"+Labels[23]+"</td>" calendar +=" <td align=center width=\"14%\" class=\"daytitle\">"+Labels[24]+"</td>" calendar +=" <td align=center width=\"14%\" class=\"daytitle\">"+Labels[25]+"</td>" calendar +=" <td align=center width=\"14%\" class=\"daytitle\">"+Labels[26]+"</td>" calendar +=" <td align=center width=\"14%\" class=\"daytitle\">"+Labels[27]+"</td>" calendar +=" <td align=center width=\"14%\" class=\"daytitle\">"+Labels[28]+"</td>" calendar +=" <td align=center width=\"14%\" class=\"daytitle\">"+Labels[29]+"</td>" calendar +=" </tr>" // Create the days. wholeDate = month + "/01/" + year thedate = new Date(wholeDate) firstDay = thedate.getDay() selectedmonth = mthIdx; var today = new Date(); var month=today.getMonth(); var presentMonth=eval(today.getMonth()+1); var presentDay= today.getDate(); var presentYear = today.getFullYear(); var presentDate =new Date(presentMonth + "/" + presentDay + "/" + presentYear); var currentYear=today.getYear(); var nextYear=currentYear + 1; var thisyear = today.getYear() + 1900; selectedyear = year var lastDay = (endday + firstDay+1) var iRows =0 calendar +=" <tr>" for (var i = 1; i < lastDay; i++) { var changeingDay =(i-firstDay); var changigDate =new Date(changingmonth + "/" + (i-firstDay) + "/" + year) if ( changigDate == presentDate ) { changeingDay = "<span class='calend33'>" + changeingDay + "</span>" ; } if (i <= firstDay) { calendar +=" <td class='emptyDay'> </td>" } else { if(changigDate <= InventoryDate) { if( changigDate >= presentDate) { var changingTime = changigDate.getTime(); var presentTime= presentDate.getTime(); if(changingTime==presentTime) { changeingDay = "<span class='today'>" + changeingDay + "</span>" ; } var sday = i-firstDay; var smonth = selectedmonth; if (selectedmonth < 10) { smonth="0"+selectedmonth;} if (sday < 10) { sday = "0"+sday;} var aDateObj = new Date(parent.getcurrentADay()); var dDateObj = new Date(parent.getcurrentDDay()); var sDateObj = new Date(smonth+"/"+sday+"/"+selectedyear); if (sDateObj.valueOf()==aDateObj.valueOf()) { calendar +=" <td class='calArrival' align=center>" } else if (sDateObj.valueOf() == dDateObj.valueOf()) { calendar +=" <td class='calDepart' align=center>" } else if (sDateObj.valueOf() < dDateObj.valueOf() && sDateObj.valueOf() > aDateObj.valueOf()) { calendar +=" <td class='betweenAD' align=center>" } else { calendar +=" <td class='afterToday' align=center>" } calendar +="<span ID='"+cal+(i-firstDay)+"'><a href='JavaScript calendar += "\", \"" + language + "\", \"" + locale + "\",\"" + callBackFn + "\");'>"+ changeingDay +"</a></span></td>" } else { calendar +=" <td class='beforeToday' align=center><span ID='"+cal+(i-firstDay)+"'><a 'JavaScript calendar += "\", \"" + language + "\", \"" + locale + "\",\"" + callBackFn + "\");'>"+(i-firstDay) +"</a></span></td>" } } else { var sday = i-firstDay; var smonth = selectedmonth; if (selectedmonth < 10) { smonth="0"+selectedmonth;} if (sday < 10) { sday = "0"+sday;} var aDateObj = new Date(parent.getcurrentADay()); var dDateObj = new Date(parent.getcurrentDDay()); var sDateObj = new Date(smonth+"/"+sday+"/"+selectedyear); if (sDateObj.valueOf()==aDateObj.valueOf()) { calendar +=" <td class='calArrival' align=center>" } else if (sDateObj.valueOf() == dDateObj.valueOf()) { calendar +=" <td class='calDepart' align=center>" } else if (sDateObj.valueOf() < dDateObj.valueOf() && sDateObj.valueOf() > aDateObj.valueOf()) { calendar +=" <td class='betweenAD' align=center>" } else { calendar +=" <td class='afterToday' align=center>" } calendar +="<div align=center><span ID='"+cal+(i-firstDay)+"'><a 'JavaScript calendar += "\", \"" + language + "\", \"" + locale + "\",\"" + callBackFn + "\");'>"+(i-firstDay) +"</a></span></font></font></div></td>" } } if (i % 7 == 0 ) { if (i != lastDay-1) { calendar +=" </tr><tr>" iRows = iRows + 1 } else { iRows = iRows } } } calendar +=" </tr>" calendar +=" </tr></table>" sdiv = document.getElementById(cal); sdiv.innerHTML = calendar; if(action=="nextmo"){ generateCalendar(aord,"cal1",goPrevMonth ,prevYear ,formStr ,dayCtrlStr, monthCtrlStr ,yearCtrlStr ,dowCtrlStr ,language ,locale,callBackFn,"") //parent.setCurrFcs("nocal"); parent.document.getElementById(dowCtrlStr).focus(t rue); // var clickCount = 0; } else if(action=="premo"){ yr = year; if(goNextMonth==1){ yr = nextYear; } generateCalendar(aord,"cal2",goNextMonth ,yr ,formStr ,dayCtrlStr, monthCtrlStr ,yearCtrlStr ,dowCtrlStr ,language ,locale,callBackFn,"") parent.document.getElementById(dowCtrlStr).focus(t rue); } } --> </script> |
![]() |
| Tags |
| calendar |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| calendar | unitedcraig | Webforumz Cafe | 2 | May 17th, 2008 20:22 |
| Web Calendar | simmo | Website Planning | 3 | Jun 29th, 2007 11:28 |
| Calendar in ASP.NET | Rajeev | ASP.NET Forum | 2 | Apr 18th, 2007 14:01 |
| Urgent help in Javascript calendar display | cloudymegz | JavaScript Forum | 3 | Jan 8th, 2006 14:37 |
| Calendar | accessman | Databases | 0 | Sep 19th, 2005 07:10 |