Desperately need help - PLEASE!

I

itcassy

I have posted my question on a couple other sites and have not
received any response. I desperately need to get this calendar
finished for a hospital. I did get a little help on the webmasters
forum, but unfortunately, it did not work.

I am working with Matt Kruse's Javascript Toolbox calendar popup and
have everything working correctly. I need to not only disable today's
date, but also the next two days. For the form I am working on, they
do not want people to be able to pick a date earlier than 3 days in
advance. I would appreciate any help anyone can provide. I cannot
figure out how to add more time to the disabled portion of the script.
The form script is below:

Dates disabled: Anything up to today, December 25, 2007, and anything
after January 1, 2008.

<SCRIPT LANGUAGE="JavaScript" ID="js17">
var now = new Date();
var cal17 = new CalendarPopup("testdiv1");
cal17.setCssPrefix("TEST");
cal17.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));
cal17.addDisabledDates("12/25/2006");
cal17.addDisabledDates("Jan 1, 2008",null);
</SCRIPT>

<input type="text" name="date17" value="" size=25>
<A HREF="#"
onClick="cal17.select(document.forms[0].date17,'anchor17','MM/dd/
yyyy'); return false;"
TITLE="cal17.select(document.forms[0].date17,'anchor17','MM/dd/yyyy');
return false;" NAME="anchor17" ID="anchor17">select</A>

And the javascript can be referenced at: http://www.mattkruse.com/javascript/calendarpopup/

Thank you in advance for any help.

-------------------------------------------------------------------------------------------

The person on the other forum posted a revision to the code, but that
does NOT work :(


Untested, but try this. My lines indented for clarity:

<SCRIPT LANGUAGE="JavaScript" ID="js17">
var now = new Date();

var tomorrow = new Date();
tomorrow.setTime(now.getTime() + 86400000)

var dayftertomorrow = new Date();
dayftertomorrow.setTime(now.getTime() + 172800000)

var cal17 = new CalendarPopup("testdiv1");
cal17.setCssPrefix("TEST");
cal17.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));

call7.addDisabledDates(null,formatDate(tomorrow,"yyyy-MM-dd"));

call7.addDisabledDates(null,formatDate(dayaftertomorrow,"yyyy-MM-
dd"));

cal17.addDisabledDates("12/25/2006");
cal17.addDisabledDates("Jan 1, 2008",null);
</SCRIPT>

Any suggestions from anyone?
 
I

itcassy

(e-mail address removed) said the following on 9/4/2007 9:08 PM:
I have posted my question on a couple other sites and have not
received any response. I desperately need to get this calendar
finished for a hospital. I did get a little help on the webmasters
forum, but unfortunately, it did not work.
I am working with Matt Kruse's Javascript Toolbox calendar popup and
have everything working correctly.

Any suggestions from anyone?

Did you try asking Matt himself? He posts occasionally here but not very
often. His email address is on his website somewhere (or he may have the
contact form now). When working with a library, the best place to ask a
question about that library is from the author of the library.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/


Yes - I did ask there as well
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
oglegroups.com>, Wed, 5 Sep 2007 01:08:09, (e-mail address removed) posted:

In future, use an informative Subject line.

Hospitals can work 24 hours/day; and even administrators might have to
work late.

var now = new Date();

var tomorrow = new Date();

That may be called on the following day, getting a different date. Use
var tomorrow = new Date(+now);
which is also quicker.
tomorrow.setTime(now.getTime() + 86400000)

Fails for an hour on two days per year in many places, use setDate().
864e5 is leas easily mis-typed.
var dayftertomorrow = new Date();
dayftertomorrow.setTime(now.getTime() + 172800000)

Fails for an hour on four days per year in many places.


It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 
E

Evertjan.

Dr J R Stockton wrote on 05 sep 2007 in comp.lang.javascript:
That may be called on the following day, getting a different date. Use
var tomorrow = new Date(+now);
???

which is also quicker.

var now = new Date();
var tomorrow = now;
tomorrow.setDate(tomorrow.getDate()+1)
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>
Dr J R Stockton wrote on 05 sep 2007 in comp.lang.javascript:


???

If, above, now is set at 23:59:59.999999 and tomorrow is then set at
00:00:00.000001, they will refer to different days.

Subsequent OP code incremented tomorrow (badly)
var now = new Date();
var tomorrow = now;
tomorrow.setDate(tomorrow.getDate()+1)

That will change now, which is used subsequently by the OP.

To clone a Date Object, getting a second one of the same value, I prefer

D2 = new Date(+D1)

for speed, reliability, and brevity.

Your way of incrementing the date is correct; but the OP's will be
faster and adequate expect probably on particular dates when near
midnight.
 
E

Evertjan.

Dr J R Stockton wrote on 08 sep 2007 in comp.lang.javascript:
That will change now, which is used subsequently by the OP.

To clone a Date Object, getting a second one of the same value, I prefer

D2 = new Date(+D1)

Elementary, my dear Wat-John, except that I did not know that yet.
for speed, reliability, and brevity.

Your way of incrementing the date is correct; but the OP's will be
faster and adequate expect probably on particular dates when near
midnight.

I expect you ment except?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top