Results 1 to 2 of 2

Thread: events calendar java script

  1. #1
    Join Date
    Dec 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default events calendar java script

    this http://www.javascriptkit.com/script/...calendar.shtml calendar is great but the script counts number of date beyond the actual date. it does not also take into account the leap month (FEB). Can the developer or any developer here help to collect the problem?

    here is some of the code from which i think is the problem

    Code:
    var thisDate = 1;							// Tracks current date being written in calendar
    var wordMonth = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
    var today = new Date();							// Date object to store the current date
    var todaysDay = today.getDay() + 1;					// Stores the current day number 1-7
    var todaysDate = today.getDate();					// Stores the current numeric date within the month
    var todaysMonth = today.getUTCMonth() + 1;				// Stores the current month 1-12
    var todaysYear = today.getFullYear();					// Stores the current year
    var monthNum = todaysMonth;						// Tracks the current month being displayed
    var yearNum = todaysYear;						// Tracks the current year being displayed
    var firstDate = new Date(String(monthNum)+"/1/"+String(yearNum));	// Object Storing the first day of the current month
    var firstDay = firstDate.getUTCDay();					// Tracks the day number 1-7 of the first day of the current month
    var lastDate = new Date(String(monthNum+1)+"/0/"+String(yearNum));	// Tracks the last date of the current month
    var numbDays = 0;
    var calendarString = "";
    var eastermonth = 0;
    var easterday = 0;
    
    
    function changedate(buttonpressed) {
    	if (buttonpressed == "prevyr") yearNum--;
    	else if (buttonpressed == "nextyr") yearNum++;
    	else if (buttonpressed == "prevmo") monthNum--;
    	else if (buttonpressed == "nextmo") monthNum++;
    	else  if (buttonpressed == "return") { 
    		monthNum = todaysMonth;
    		yearNum = todaysYear;
    	}
    
    	if (monthNum == 0) {
    		monthNum = 12;
    		yearNum--;
    	}
    	else if (monthNum == 13) {
    		monthNum = 1;
    		yearNum++
    	}
    
    	lastDate = new Date(String(monthNum+1)+"/0/"+String(yearNum));
    	numbDays = lastDate.getDate();
    	firstDate = new Date(String(monthNum)+"/1/"+String(yearNum));
    	firstDay = firstDate.getDay() + 1;
    	createCalendar();
    	return;
    }
    
    
    function easter(year) {
    // feed in the year it returns the month and day of Easter using two GLOBAL variables: eastermonth and easterday
    var a = year % 19;
    var b = Math.floor(year/100);
    var c = year % 100;
    var d = Math.floor(b/4);
    var e = b % 4;
    var f = Math.floor((b+8) / 25);
    var g = Math.floor((b-f+1) / 3);
    var h = (19*a + b - d - g + 15) % 30;
    var i = Math.floor(c/4);
    var j = c % 4;
    var k = (32 + 2*e + 2*i - h - j) % 7;
    var m = Math.floor((a + 11*h + 22*k) / 451);
    var month = Math.floor((h + k - 7*m + 114) / 31);
    var day = ((h + k - 7*m +114) % 31) + 1;
    eastermonth = month;
    easterday = day;
    }
    
    
    function createCalendar() {
    	calendarString = '';
    	var daycounter = 0;
    	calendarString += '<table width="312" border="1" cellpadding="0" cellspacing="1">';
    	calendarString += '<tr>';
    	calendarString += '<td align=\"center\" valign=\"center\" width=\"40\" height=\"40\"><a href=\"#\" onMouseOver=\"document.PrevYr.src=\'images\/PrevYrOn40x40\.jpg\';\" onMouseOut=\"document.PrevYr.src=\'images\/PrevYrOff40x40\.jpg\';\" onClick=\"changedate(\'prevyr\')\"><img name=\"PrevYr\" src=\"images\/PrevYrOff40x40\.jpg\" width=\"40\" height=\"40\" border=\"0\" alt=\"Prev Yr\"\/><\/a><\/td>';
    	calendarString += '<td align=\"center\" valign=\"center\" width=\"40\" height=\"40\"><a href=\"#\" onMouseOver=\"document.PrevMo.src=\'images\/PrevMoOn40x40\.jpg\';\" onMouseOut=\"document.PrevMo.src=\'images\/PrevMoOff40x40\.jpg\';\" onClick=\"changedate(\'prevmo\')\"><img name=\"PrevMo\" src=\"images\/PrevMoOff40x40\.jpg\" width=\"40\" height=\"40\" border=\"0\" alt=\"Prev Mo\"\/><\/a><\/td>';
    	calendarString += '<td bgcolor=\"#C8C896\" align=\"center\" valign=\"center\" width=\"128\" height=\"40\" colspan=\"3\"><b>' + wordMonth[monthNum-1] + '&nbsp;&nbsp;' + yearNum + '<\/b><\/td>';
    	calendarString += '<td align=\"center\" valign=\"center\" width=\"40\" height=\"40\"><a href=\"#\" onMouseOver=\"document.NextMo.src=\'images\/NextMoOn40x40\.jpg\';\" onMouseOut=\"document.NextMo.src=\'images\/NextMoOff40x40\.jpg\';\" onClick=\"changedate(\'nextmo\')\"><img name=\"NextMo\" src=\"images\/NextMoOff40x40\.jpg\" width=\"40\" height=\"40\" border=\"0\" alt=\"Next Mo\"\/><\/a><\/td>';
    	calendarString += '<td align=\"center\" valign=\"center\" width=\"40\" height=\"40\"><a href=\"#\" onMouseOver=\"document.NextYr.src=\'images\/NextYrOn40x40\.jpg\';\" onMouseOut=\"document.NextYr.src=\'images\/NextYrOff40x40\.jpg\';\" onClick=\"changedate(\'nextyr\')\"><img name=\"NextYr\" src=\"images\/NextYrOff40x40\.jpg\" width=\"40\" height=\"40\" border=\"0\" alt=\"Next Yr\"\/><\/a><\/td>';
    	calendarString += '<\/tr>';
    	calendarString += '<tr>';
    	calendarString += '<td bgcolor=\"#DDDDDD\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Sun<\/td>';
    	calendarString += '<td bgcolor=\"#DDDDDD\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Mon<\/td>';
    	calendarString += '<td bgcolor=\"#DDDDDD\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Tue<\/td>';
    	calendarString += '<td bgcolor=\"#DDDDDD\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Wed<\/td>';
    	calendarString += '<td bgcolor=\"#DDDDDD\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Thu<\/td>';
    	calendarString += '<td bgcolor=\"#DDDDDD\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Fri<\/td>';
    	calendarString += '<td bgcolor=\"#DDDDDD\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Sat<\/td>';
    	calendarString += '<\/tr>';
    
    	thisDate == 1;
    
    	for (var i = 1; i <= 6; i++) {
    		calendarString += '<tr>';
    		for (var x = 1; x <= 7; x++) {
    			daycounter = (thisDate - firstDay)+1;
    			thisDate++;
    			if ((daycounter > numbDays) || (daycounter < 1)) {
    				calendarString += '<td align=\"center\" bgcolor=\"#888888\" height=\"30\" width=\"40\">&nbsp;<\/td>';
    			} else {
    				if (checkevents(daycounter,monthNum,yearNum,i,x) || ((todaysDay == x) && (todaysDate == daycounter) && (todaysMonth == monthNum))){
    					if ((todaysDay == x) && (todaysDate == daycounter) && (todaysMonth == monthNum)) {
    						calendarString += '<td align=\"center\" bgcolor=\"#AAFFAA\" height=\"30\" width=\"40\"><a href=\"javascript:showevents(' + daycounter + ',' + monthNum + ',' + yearNum + ',' + i + ',' + x + ')\">' + daycounter + '<\/a><\/td>';
    					}
     					else	calendarString += '<td align=\"center\" bgcolor=\"#FFFFC8\" height=\"30\" width=\"40\"><a href=\"javascript:showevents(' + daycounter + ',' + monthNum + ',' + yearNum + ',' + i + ',' + x + ')\">' + daycounter + '<\/a><\/td>';
    				} else {
    					calendarString += '<td align=\"center\" bgcolor=\"#DDFFFF\" height=\"30\" width=\"40\">' + daycounter + '<\/td>';
    				}
    			}
    		}
    		calendarString += '<\/tr>';
    	}
    
    	calendarString += '<tr><td colspan=\"7\" nowrap align=\"center\" valign=\"center\" bgcolor=\"#C8C896\" width=\"280\" height=\"22\"><a href=\"javascript:changedate(\'return\')\"><b>Show Current Date<\/b><\/a><\/td><\/tr><\/table>';
    
    	var object=document.getElementById('calendar');
    	object.innerHTML= calendarString;
    	thisDate = 1;
    }
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	1.jpg 
Views:	67 
Size:	77.3 KB 
ID:	5993   Click image for larger version. 

Name:	2.jpg 
Views:	67 
Size:	74.5 KB 
ID:	5994  
    Last edited by jscheuer1; 12-10-2016 at 01:47 PM. Reason: format

  2. #2
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    You might do better by looking at Fast Cal developed by our very own Beverleyh.

Similar Threads

  1. only one user can add events in calendar
    By rhodarose in forum PHP
    Replies: 0
    Last Post: 08-23-2010, 03:52 AM
  2. School Events Calendar
    By renegmast in forum Looking for such a script or service
    Replies: 2
    Last Post: 01-16-2010, 07:20 PM
  3. Will Pay for Help with Events Calendar
    By kuau in forum General Paid Work Requests
    Replies: 4
    Last Post: 02-20-2009, 04:20 PM
  4. Replies: 1
    Last Post: 04-21-2008, 10:07 AM
  5. Community Events Calendar
    By kuau in forum Computer hardware and software
    Replies: 0
    Last Post: 03-04-2008, 02:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •