Calendar Display

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.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 20th, 2007, 21:59
New Member
Join Date: Aug 2007
Location: US
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Calendar Display

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.
Attached Files
File Type: rtf whack_cal.rtf (847.9 KB, 10 views)
File Type: txt embed_calendar.txt (26.1 KB, 5 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 20th, 2007, 22:24
New Member
Join Date: Aug 2007
Location: US
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Re: Calendar Display

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\">&lt;</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\">&lt;</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\">&gt;</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\">&gt;</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'>&nbsp;</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='JavaScriptarent.clickedCalendar(\""+aord+ "\", \"" + cal + "\"," + (i-firstDay) + ","+ selectedmonth + ","+ selectedyear + ", \"" + formStr + "\", \"" + dayCtrlStr + "\", \"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr
calendar += "\", \"" + language + "\", \"" + locale + "\",\"" + callBackFn + "\");'>"+ changeingDay +"</a></span></td>"
}
else
{
calendar +=" <td class='beforeToday' align=center><span ID='"+cal+(i-firstDay)+"'><a 'JavaScriptarent.clickedCalendar(\""+aord+ "\", \"" + cal + "\"," + (i-firstDay) + ","+ selectedmonth + ","+ selectedyear + ", \"" + formStr + "\", \"" + dayCtrlStr + "\", \"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr
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 'JavaScriptarent.clickedCalendar(\""+aord+ "\", \"" + cal + "\"," + (i-firstDay) + ","+ selectedmonth + ","+ selectedyear + ", \"" + formStr + "\", \"" + dayCtrlStr + "\", \"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr
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>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
calendar

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 21:04.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved