dominoGuru.com

Your Development & Design Resource

Dynarch Calendar - Date Blockers

A client of mine has a "Time & Attendance" database that I was updating the code to be a little more web-savvy. Using the open source DHTML calendar from Dynarch, I was able to give a pretty snazzy looking calendar tool. But the functionality of the time sheets called for the user to select a Sunday as the start date for the timesheet, and if they did not it would alert them to make another selection. Instead of doing this, I decided to only allow the user to select a Sunday from the DHTML calendar itself and, along with the assistance of the DominoGuru himself, came up with the JavaScript function to add to the calendar to achieve this.

This particular calendar has the functionality built in to run a JavaScript function to basically "turn off" dates you do not want to have available. So I used the code below to turn off all dates except Sundays:

function dateStatus(date) {
if (date.getDay() != 0) {
 return true; // true says "disable"
 } else {
 return false; // leave other dates enabled
}
}

...then in the Calendar.setup code I added this:

Calendar.setup(
{
 inputField:"calendar_date",
 ifFormat:"%m/%e/%Y",
 button:"calendar_trigger",
 align:"BR",
 singleClick:"false",
 dateStatusFunc:dateStatus
}
)
and BINGO!

Dynarch Calendar with Dates Excluded


Michael Smelser
Lotus Notes/Domino Application Developer
Lotus911
770.517.0092 (phone) | 404.663.1058 (cell) | 678.594.6756 (fax)
http://www.Lotus911.com

Lotus911!


About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of dominoGuru.com, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.



More from dominoGuru.com


dominoGuru.com is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, dominoGuru.com by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.