Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 27th, 2006, 11:45 AM   #1
aaroncampbell
Newbie
 
Join Date: Oct 2006
Posts: 7
Rep Power: 0 aaroncampbell is on a distinguished road
Strange getMonth/setMonth problem

Ok, the code is attached, and you can use it by adding onfocus="cal.showCal(this);" to any text input like this:
<input name="demo" type="text" maxlength="10" size="10" onfocus="cal.showCal(this);" />
Now, The problem I have it that the month down button doesn't work, and the month up button goes 2 months at a time...except from Dec to Jan...which it does correctly.

Anyway, It sounds easy, but I tried manually changing the adjustment in the Calendar.prototype.changeMonth function like this:
this.current.setMonth(this.current.getMonth()+1);
And it still goes by 2. So I tried this:
this.current.setMonth(this.current.getMonth());
And it doesn't change (as expected), so I tried this:
this.current.setMonth(this.current.getMonth()-1);
And it doesn't change!!! How can this.current.getMonth()-1 == this.current.getMonth()!!!

Anyway, the problem is that creating a test case didn't seem to work...I couldn't repeat the glitch. Maybe someone can find my glaring error? I know that this system worked not that long ago...I HAVE made changes, but I have no idea where this went wrong...
Attached Files
File Type: zip calendar.zip (4.1 KB, 22 views)
aaroncampbell is offline   Reply With Quote
Old Oct 27th, 2006, 4:23 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I find two references to "setMonth" in the code, both invocations. Where's the function definition?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 27th, 2006, 4:31 PM   #3
aaroncampbell
Newbie
 
Join Date: Oct 2006
Posts: 7
Rep Power: 0 aaroncampbell is on a distinguished road
http://developer.mozilla.org/en/docs...:Date:setMonth
It's part of the Date object.
aaroncampbell is offline   Reply With Quote
Old Oct 31st, 2006, 2:04 PM   #4
aaroncampbell
Newbie
 
Join Date: Oct 2006
Posts: 7
Rep Power: 0 aaroncampbell is on a distinguished road
I've used alerts, and console.logs all over the place, and I'm still lost. One thing I DO know is that the function isn't running twice. It only runs once. I log the adjustment (1 or -1 as expected), I run getMonth (0-11, and always as expected), I log the math (-1 - 12, and again as expected), and then I setMonth, and log getMonth...and it's OFF!

Summary: I'm still lost.

I'm attaching 3 files... the .js, the .css, and a .html that will let you test it.
Attached Files
File Type: zip calendar.zip (4.8 KB, 12 views)
aaroncampbell is offline   Reply With Quote
Old Oct 31st, 2006, 2:49 PM   #5
aaroncampbell
Newbie
 
Join Date: Oct 2006
Posts: 7
Rep Power: 0 aaroncampbell is on a distinguished road
As it turns out, the date that I was adjusting was Month/LastDayOfMonth/Year, so it would be something like: 10/31/2006 and it would try to change it to 11/31/2006 (which doesn't exist, 11 only has 30 days). It doesn't know what to do with that, so it interprets it as 12/01/2006. I simply added this.current.setDate(1); before the setMonth and it worked perfectly.
aaroncampbell is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
strange problem brad sue C++ 3 Sep 1st, 2006 8:50 AM
Strange behavior: getting different results from the same input on a function. WTH? pulpfiction C 1 Mar 28th, 2006 11:43 PM
Strange Problem? magic_e PHP 10 Feb 9th, 2006 8:54 PM
cgi/perl script + IE problem joyceshee Perl 2 Jan 24th, 2006 11:10 AM
Variable array problem Hintshigen C 6 Apr 10th, 2005 2:35 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:11 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC