May I suggest a slightly different way to do this? I hope I'm not taking the
fun out of this, but I've done this one before, and it's easier to just post
the code :) Gotta love those snippets.
function IsLeapYear(Year) {
if(Math.round(Year/4) == Year/4){
if(Math.round(Year/100) == Year/100){
if(Math.round(Year/400) == Year/400)
return true;
else
return false;
}
else
return true;
}
return false;
}
function getDays(month, year) {
// create array to hold number of days in each month
var ar = new Array(12)
ar[0] = 31;
ar[1] = (IsLeapYear(year)) ? 29 : 28;
ar[2] = 31;
ar[3] = 30;
ar[4] = 31;
ar[5] = 30;
ar[6] = 31;
ar[7] = 31;
ar[8] = 30;
ar[9] = 31;
ar[10] = 30;
ar[11] = 31
return ar[month];
}
function changeMonth(month, year) {
days = getDays(month, year);
document.formName.selectName.options.length = 1;
for (i = 0; i != days; i++) {
o = new Option(i, i, false, false);
document.formName.selectName.options[document.formName.selectName.length]
= o;
}
}
<form name="formName">
<select name="selectName">
<option value="1">1 </option>
</select>
</form>
jon
----- Original Message -----
From: "Yager, Brian T Contractor/NCCIM" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, February 21, 2002 4:39 PM
Subject: OT: Any Javascript people out there? I need help with select bo
xes...
> sorry about the OT post..I need help with a select box. I am making 2
select
> boxes (Month and Day). when the user changes the month, I want the
javascript
> to delete what is in the day select box and fill it with the number of
days in
> that month. I have the deleting part working. It just won't add. I'm
not sure
> what I need to do. Here is my code(Please ignore that I HAVE to use ASP
for
> this)..
>
______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
Instant Activation � $99/Month � Free Setup
http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists