View Full Version : Javascript Calendar

07-08-2004, 09:55 AM

I'm looking for a calendar like the following - http://javascript.internet.com/calendars/cookie-calendar.html

I want the calendar to read events from a text file so when you when click on the date it will display the events for that date. If there are any events, I would like some text in the day box.... http://javascript.internet.com/calendars/cookie-calendar/calendar.html

Any ideas on how to do this? Or has anyone seen a better example?


07-08-2004, 12:12 PM
With the bit about reading form a text file, if it resides on the viewers PC, its impossible to acess. This is because when Javascript was designed, to make it safe for users, Javascript cannot acess files or write to files on a users PC. The only way to store data on a users PC is using a Cookie, and these can be blocked easily.

It would be possible tough with a Java Applet and some CGI, but im no expert in either. Sorry. For the Java try this site, java.net.

Sorry :(


07-08-2004, 04:23 PM

Sorry - I haven't explained it well.

I would like it to read from a .js file on the web server that I can physically edit to put new events on.

Any ideas

07-08-2004, 08:24 PM
Sos, my mistake. It should be OK this way. :thumbsup:

07-09-2004, 09:51 AM
any ideas?

07-09-2004, 12:10 PM
Ill work on it. I cant promise much though.

07-09-2004, 12:39 PM
You should store the events in an array that are structured like this:

var arrEvents = new Array();
arrEvents['07-09-2004'] = new Array();
arrEvents['07-09-2004'][0] = "event 1";
arrEvents['07-09-2004'][1] = "event 2";
arrEvents['07-09-2004'][2] = "event 3";

arrEvents['07-10-2004'] = new Array();
arrEvents['07-10-2004'][0] = "event 1";
arrEvents['07-10-2004'][1] = "event 2";


Then call this in each date link passing the corresponding date in mm-dd-yyyy format or using your desired format.

function viewEvents(dateIndex){
var temp = arrEvents[dateIndex];
if (temp){
var evts = '';
for (var i=0;i<temp.length;i++){
evts += temp[i] + '\n';
if (evts!=''){
alert('Events for ' + dateIndex + ':\n' + evts);
else {
alert('No events for ' + dateIndex + ".");
return false;
<a href="#" onclick="return viewEvents('07-09-2004')">9</a>