Solved

JavaScript Calendar Popup

Posted on 2009-05-08
6
1,480 Views
Last Modified: 2012-05-06
Hi,

I am using the CalendarPopup.js available at http://www.mattkruse.com/javascript/calendarpopup/ in order to provide a popup calendar in a form.  Everything is working well but I can't seem to work out how to disable dates 1 week ahead of the current date.  

I have currently managed to get it to allow selection of the days in the week I want and also I have disabled every date before the current date.  But now I am looking to get it to disable selection of any of the selectable days 1 week ahead of the current date.

I hope this makes sense, and thank you in advance for any assistance.
var now  = new Date();
var cal1 = new CalendarPopup("caldiv");
cal1.showNavigationDropdowns();
cal1.setCssPrefix("TEST");
cal1.setDisabledWeekDays(0,2,3,4,5,6);
cal1.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
cal1.addDisabledDates("01/01/2007");

Open in new window

0
Comment
Question by:john_hollings
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 12

Expert Comment

by:Gibu George
ID: 24336229
cal1.addDisabledDates(formatDate(now.getDate()-1,"yyyy-MM-dd"));
cal1.addDisabledDates(null,formatDate(now.getDate()+8,"yyyy-MM-dd"));
0
 
LVL 5

Author Comment

by:john_hollings
ID: 24337968
Hi I did try something similar to this, however I used the code you supplied and I got the same result, it just allows me to select previous dates which I am also need disabled.
<script language="JavaScript">
	var now  = new Date();
	var cal1 = new CalendarPopup("caldiv");
	cal1.showNavigationDropdowns();
	cal1.setCssPrefix("TEST");
	cal1.setDisabledWeekDays(0,2,3,4,5,6);
	cal1.addDisabledDates(formatDate(now.getDate()-1,"yyyy-MM-dd"));
	cal1.addDisabledDates(null,formatDate(now.getDate()+8,"yyyy-MM-dd"));
	cal1.addDisabledDates("01/01/2007");
</script>

Open in new window

0
 
LVL 12

Accepted Solution

by:
Gibu George earned 500 total points
ID: 24338063
cal1.addDisabledDates(null,formatDate(now.getDate()-1,"yyyy-MM-dd"));
cal1.addDisabledDates(formatDate(now.getDate()+8,"yyyy-MM-dd"),null);

0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 12

Expert Comment

by:Gibu George
ID: 24338067
This is the correct one. I got it wrong the first time
0
 
LVL 5

Author Comment

by:john_hollings
ID: 24340211
OK thanks for the updated code.  Forgot to bring the laptop home for the weekend so will get back to you on Monday and let you know how I get on.
0
 
LVL 5

Author Comment

by:john_hollings
ID: 24353243
Hi,

Still hasn't disabled the week ahead of today's date.  I attached the code I used.
	var now  = new Date();
	var cal1 = new CalendarPopup("caldiv");
	cal1.showNavigationDropdowns();
	cal1.setCssPrefix("TEST");
	cal1.setDisabledWeekDays(0,2,3,4,5,6);
	cal1.addDisabledDates("01/01/2007");
	cal1.addDisabledDates(null,formatDate(now.getDate()-1,"yyyy-MM-dd"));
	cal1.addDisabledDates(formatDate(now.getDate()+8,"yyyy-MM-dd"),null);

Open in new window

0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question