PDA

View Full Version : Calendar script question, just need a nudge in the right direction


skullkrusher
06-18-2003, 05:00 PM
Alright, I'm trying to write my own calendar script. I've just finished a class in school of JavaScript and so I'm trying to do as much on my own as I can (so I can keep learning and hopefully get better).

Right now I've got a script that creates the calendar (the correct dates, days of the week, it even high lights the current date) but it will only display what the users 'system date' is. What I want to try now is to allow the user to select another month and have the calendar refresh with that chosen months correct days and dates.

I was just really hoping someone could kind of give me some hints as to how to start this or just a few helpful tips.

Thanks a whole bunch, I appreciate it.

beetle
06-18-2003, 05:29 PM
var today = new Date(); // today

var yesterday = new Date().setDate( today.getDate() - 1 );

var lastmonth = new Date( today.getYear(), today.getMonth() - 1, today.getDate() );

As you can see, there's more than one way to manipulate a date.

Learn all about the JS Date object and it's methods/properties here (http://www.w3schools.com/js/js_datetime.asp)

skullkrusher
06-18-2003, 05:33 PM
Thanks for that stuff, that should help a little bit. Thanks for the link too.

skullkrusher
06-20-2003, 07:08 PM
Another question, how do I get the calendar to rebuild? Any suggestions of how to do this when the user clicks the "next month" or "previous month" buttons?

beetle
06-20-2003, 07:15 PM
How are you writing it now? Via document.write() or are you making/appending DOM nodes?

skullkrusher
06-20-2003, 08:26 PM
right now I'm writing it using document.write, which would be easier for a novice JavaScript programmer?


I attached the whole thing I have so far

beetle
07-01-2003, 05:45 AM
document.write is a bit easier - but would require a page-refresh to generate new content - which means you'd have to use cookies to the query-string to carry data over the refresh.

The other option is to use DOM methods for adding/removing nodes from the document tree.

Whatcha think?

jkd
07-01-2003, 05:53 AM
I have one I wrote here:
www.jasonkarldavis.com/calender.html
(yeah, I know. misspelled even)

It uses DOM methods of insertion and deletion to update the calendar. Maybe you can learn a bit by example. :)

skullkrusher
07-02-2003, 04:14 PM
Thanks guys, I'll take a look at yours jkd and I'll try to do this by using the DOM. I appreciate the help.

skullkrusher
07-08-2003, 08:15 PM
JKD, I'm having problems accessing your site.

Thanks

ca_redwards
07-12-2003, 12:28 AM
In my javascript calendar (http://www.angelfire.com/ca/redwards/html__.calendar.html), you can specify what date to start with. Unzip the attached file and view popCal.html in your browser.

Enter a date MM/DD/YYYY in the textbox, the press the button. In the popup calendar, the date is pre-selected.

Enjoy!

:ca_redwards.