Month, Day Select boxes

# Thread: Month, Day Select boxes

1. Junior Member
Join Date
Dec 1969
Posts
12

## Month, Day Select boxes

I need some help in a making a couple select boxes. i want the first to display months(this i can do) then i want the other to display the days of that month that is selected. I want them to be on the same page so when i select a month the days are generated thanks

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## And how many...

...does February get??? If the user hasn&#039;t selected the YEAR yet, then you don&#039;t *KNOW* the answer!<BR><BR>I strongly urge you to reconsider this.<BR><BR>Just put in days from 1 to 31.<BR><BR>And then, when the user submits the form, you check to make sure that the day number is in range for that month in that year. If not, give them an error and make them choose another day. Chances are 99.4% that nobody will ever get the error, unless they are testing to see if you are smart enough to handle it right.<BR><BR>

3. Junior Member
Join Date
Dec 1969
Posts
12

## RE: And how many...

my bad you are also selecting a year too

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## My point was...

...that you CAN NOT give the right number of DAY selections until AFTER the user selects *both* a month and a year. BOTH.<BR><BR>So don&#039;t bother doing it dynamically. Just put all the days from 1 to 31 there and be happy.<BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
293

## Bills right, but so what else is new?

In all seriousness, tho, all of the days are standard, except for February. February has 27 days except for years where year mod 4 = 2 (1998,2002,2004...). It follows that you could have a 12 element array where element 2 (Feb) would get changed depending on the year.<BR><BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
96,118

## Ummm....27 days?

So you have a March Zero on your calendar then? Or only 364 days in your year?<BR><BR>&#060;grin&#062; I know, it was just a typo, but given the context it was truly funny! &#060;/grin&#062;<BR><BR>Anyway, the important point was that building the list of the days in a month dynamically simply isn&#039;t worth the trouble. You have to make the user give you month and year first, and then if he/she changes his mind about either one you have to rebuild the list. Etc. And nobody except somebody trying to mess with your mind/code is going to put in an illegal day, anyway. So the "ex post facto" validation check is more than adequate.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•