473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Javascript problem not sure what this would be called



Here is the URL of my page:

http://www.kevsblues.com/CATER/din.html

________________________________________

I can not understand how to get this so the page
reads "Only 9 days till Thanksgiving"
or whatever the date may be. (Xmass ect....)

I could not get this to work
so I put the

"Leave the Party to KevsBlues Catering"

I have a funny feeling there may lie the problem...

But

any help please

Thanks

Kevin

______________________________________

var holidayCntMsg = "Leave the party to KEVSBLues Catering"
var curDay = new Date()
var tMonth = curDay.getMonth()
function HolidayDays() {
switch (tMonth) {
case 2:
var tHoliday = new Date("March 17, 2001")
var curHoliday = tHoliday.getTime()-curDay.getTime()
if (curHoliday > 0) {
curHoliday = Math.ceil(curHoliday / (1000*60*60*24))
holidayCntMsg = "Only " +curHoliday+ " days until St. Patrick's Day!"
}
break
case 6:
var tHoliday = new Date("July 4, 2001")
var curHoliday = tHoliday.getTime()-curDay.getTime()
if (curHoliday > 0) {
curHoliday = Math.ceil(curHoliday / (1000*60*60*24))
holidayCntMsg = "Only " +curHoliday+ " days until the 4<sup>th</sup> of July!"
}
break
case 9:
var tHoliday = new Date("October 31, 2001")
var curHoliday = tHoliday.getTime()-curDay.getTime()
if (curHoliday > 0) {
curHoliday = Math.ceil(curHoliday / (1000*60*60*24))
holidayCntMsg = "Only " +curHoliday+ " days until Halloween!"
}
break
case 10:
var tHoliday = new Date("November 22, 2001")
var curHoliday = tHoliday.getTime()-curDay.getTime()
if (curHoliday > 0) {
curHoliday = Math.ceil(curHoliday / (1000*60*60*24))
holidayCntMsg = "Only " +curHoliday+ " days until Thanksgiving!"
}
break
case 11:
var tHoliday = new Date("December 25, 2001")
var curHoliday = tHoliday.getTime()-curDay.getTime()
if (curHoliday > 0) {
curHoliday = Math.ceil(curHoliday / (1000*60*60*24))
holidayCntMsg = "Only " +curHoliday+ " days til CHRISTMAS!"
}
break
}
return holidayCntMsg
}

--
http://www.soundclick.com/kevinduggan

http://www.kevsblues.com
Jul 23 '05 #1
4 1294
Lee
Kevin Duggan said:

Here is the URL of my page:

http://www.kevsblues.com/CATER/din.html

________________________________________

I can not understand how to get this so the page
reads "Only 9 days till Thanksgiving"
or whatever the date may be. (Xmass ect....)


Change all your dates from 2001 to 2004.

Jul 23 '05 #2
JRS: In article <ch********@drn.newsguy.com>, dated Mon, 6 Sep 2004
20:49:39, seen in news:comp.lang.javascript, Lee
<RE**************@cox.net> posted :
Kevin Duggan said:
http://www.kevsblues.com/CATER/din.html

I can not understand how to get this so the page
reads "Only 9 days till Thanksgiving"
or whatever the date may be. (Xmass ect....)


Change all your dates from 2001 to 2004.


How will that help for St Patrick's Day and US Independence Day? The
November date will need to be recalculated, too.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #3
JRS: In article <06*****************************@REMOVE.uml.edu> , dated
Tue, 7 Sep 2004 02:33:06, seen in news:comp.lang.javascript, Kevin
Duggan <ke**********@REMOVE.uml.edu> posted :
I can not understand how to get this so the page
reads "Only 9 days till Thanksgiving"
or whatever the date may be. (Xmass ect....)
ect?

var holidayCntMsg = "Leave the party to KEVSBLues Catering"
var curDay = new Date()
var tMonth = curDay.getMonth()
function HolidayDays() {
switch (tMonth) {
case 2:
var tHoliday = new Date("March 17, 2001")
var curHoliday = tHoliday.getTime()-curDay.getTime()
if (curHoliday > 0) {
curHoliday = Math.ceil(curHoliday /
(1000*60*60*24))
holidayCntMsg = "Only " +curHoliday+ " days
until St. Patrick's Day!"
}
break
case 11:
var tHoliday = new Date("December 25, 2001")
var curHoliday = tHoliday.getTime()-curDay.getTime()
if (curHoliday > 0) {
curHoliday = Math.ceil(curHoliday /
(1000*60*60*24))
holidayCntMsg = "Only " +curHoliday+ " days til
CHRISTMAS!"
}
break
}
return holidayCntMsg
}

Code posted to News should not be machine-wrapped. The author should
deal with that, rather than forcing it on his possible readers, who
generally will not want to bother.

In News, an 8-space tab is too much indentation.

Your code is repetitive; use a single function, and call it for each
case.

You need to get the year right, and to calculate the November date
accordingly.

Your day-count will change at midnight, or an hour earlier or later,
depending on the state of Summer Time at the user's location on the
current and cited date; that's inelegant. Code containing 1000*60*60*24
is always suspect, though not necessarily wrong. You can do setHours(0)
on today's date, then Math.round() on the difference (unchecked).
Given that you only show a holiday (and St.P is not AFAIK a holiday
anywhere that celebrates 04-07) once its month is started, it would be
simpler just to subtract the day-of-month.

What's UML? Lansing??

Read the newsgroup FAQ before posting, and you will often be led to the
methods you need.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #4
I can not understand how to get this so the page
reads "Only 9 days till Thanksgiving"
or whatever the date may be. (Xmass ect....)
ect?

var holidayCntMsg = "Leave the party to KEVSBLues Catering"
var curDay = new Date()
var tMonth = curDay.getMonth()
function HolidayDays() {
switch (tMonth) {
case 2:
var tHoliday = new Date("March 17, 2001")
var curHoliday = tHoliday.getTime()-curDay.getTime()
if (curHoliday > 0) {
curHoliday = Math.ceil(curHoliday /
(1000*60*60*24))
holidayCntMsg = "Only " +curHoliday+ " days
until St. Patrick's Day!"
}
break


case 11:
var tHoliday = new Date("December 25, 2001")
var curHoliday = tHoliday.getTime()-curDay.getTime()
if (curHoliday > 0) {
curHoliday = Math.ceil(curHoliday /
(1000*60*60*24))
holidayCntMsg = "Only " +curHoliday+ " days til
CHRISTMAS!"
}
break
}
return holidayCntMsg
}

Code posted to News should not be machine-wrapped. The author should
deal with that, rather than forcing it on his possible readers, who
generally will not want to bother.

In News, an 8-space tab is too much indentation.

Sorry about that thanks for the information
Your code is repetitive; use a single function, and call it for each
case.

You need to get the year right, and to calculate the November date
accordingly.
I know, I am just trying to get this to work
changing the date is easy enough


Your day-count will change at midnight, or an hour earlier or later,
depending on the state of Summer Time at the user's location on the
current and cited date; that's inelegant. Code containing 1000*60*60*24
is always suspect, though not necessarily wrong. You can do setHours(0)
on today's date, then Math.round() on the difference (unchecked).
Given that you only show a holiday (and St.P is not AFAIK a holiday
anywhere that celebrates 04-07) once its month is started, it would be
simpler just to subtract the day-of-month.

What's UML? Lansing??

U Mass Lowell
Read the newsgroup FAQ before posting, and you will often be led to the
methods you need.


--
http://www.soundclick.com/kevinduggan

http://www.kevsblues.com
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: john | last post by:
I have 2 major issues currently with javascript. 1. Doesnt anybody do any server side javascript anymore. I cant find anything on the net about it. My major issue is with database connections...
18
by: Arthur Connor | last post by:
Is there a way of extracting the Javascript code from the "normal" HTML code (e.g. similar to CSS code which can be put into a separate file) ? If you offer a solution: can I determine in your...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
22
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
6
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.