Need help from Javascript gurus

jjones

Lifer
Oct 9, 2001
15,424
2
0
I'm working on a site for a client (doing it for free, it's a friend) and I'm using javascript that assists with calendar date selection. You find a sample here:
Link

When you look at that page you will see 3 basic elements: 1) Check-in Date, 2) Number of Nights, and 3) Check-out Date. As you adjust the Check-in Date and the Number of Nights, you will see this reflected in the Check-out Date, which will change as you change the numbers in the first two elements.

The problem I am having is with Firefox browser. This script works fine in IE, but not Firefox. Whenever you modify a date, for example choose the year of 2007, then Firefox will show the year as being 107, not 2007 as it should be.

I'm not very versed at all in javascript but I can usually muddle around and get things working the way I want. Normally, I will find someone else's script and modify it for my uses. This script is, I believe, a combination of 2 other scripts I had found. It has been a while since I first made it, about a year and a half, and I'm completely stumped as to why it would work okay in IE and not Firefox. I remember this thing gave me a headache when I first put it together, and looking at it now, just gave me a headache all over again.

Can anyone help with why this won't work correctly in Firefox?
 

Modeps

Lifer
Oct 24, 2000
17,254
44
91
I seem to remember that firefox and IE handle the year function differently... like it starts counting at 1900, so if you just add 1900 to your number when in firefox/mozilla, you'll be golden.
 

jjones

Lifer
Oct 9, 2001
15,424
2
0
Originally posted by: Modeps
I seem to remember that firefox and IE handle the year function differently... like it starts counting at 1900, so if you just add 1900 to your number when in firefox/mozilla, you'll be golden.
I thought it had to be something like that because it only effects the year. I guess I'll probably have to do some browser check and then use one script for IE and another for Firefox.

Damn, and I thought with the demise of Nutscrape I wouldn't have to do this kind of crap again. I hate having to compensate for cross browser compatibility.

 

Zugzwang152

Lifer
Oct 30, 2001
12,134
1
0
Originally posted by: jjones
Originally posted by: Modeps
I seem to remember that firefox and IE handle the year function differently... like it starts counting at 1900, so if you just add 1900 to your number when in firefox/mozilla, you'll be golden.
I thought it had to be something like that because it only effects the year. I guess I'll probably have to do some browser check and then use one script for IE and another for Firefox.

Damn, and I thought with the demise of Nutscrape I wouldn't have to do this kind of crap again. I hate having to compensate for cross browser compatibility.

perhaps you should consider moving the script to the server-side then.
 

jjones

Lifer
Oct 9, 2001
15,424
2
0
Originally posted by: Zugzwang152
Originally posted by: jjones
Originally posted by: Modeps
I seem to remember that firefox and IE handle the year function differently... like it starts counting at 1900, so if you just add 1900 to your number when in firefox/mozilla, you'll be golden.
I thought it had to be something like that because it only effects the year. I guess I'll probably have to do some browser check and then use one script for IE and another for Firefox.

Damn, and I thought with the demise of Nutscrape I wouldn't have to do this kind of crap again. I hate having to compensate for cross browser compatibility.

perhaps you should consider moving the script to the server-side then.
No, it has to happen client side. Anyway, I got it working by inserting a short little browser detection script in there to get it to write one thing for IE and another for Mozilla.