It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

No of Days not loading, when calcualting with year n Month

No of Days not loading, when calcualting with year n Month

Postby shreshtha on Fri Sep 17, 2010 7:25 am

Hello All,

I am trying to fill date in date of birth field using JAVA SCRIPT. I am using C# language.
I have 3 dropdowns , one for each Year, Month, Day.When user selects Year and month , day should fill according to Year and month calculation.

I am using following script for doing same.But "Object not found" error coming.
Please help me in solving problem.
Thanks.




function AddItem()
{
var opt = document.createElement("option");
document.getElementById("ddDay").options.add(opt);
opt.value = validateDays();
}

function validateDays() {

var y = document.getElementById('<%= ddYear.ClientID %>').selectedIndex;
var m = document.getElementById('<%= ddMonth.ClientID %>').selectedIndex;
if (m == 01 || m == 03 || m == 05 || m == 07 || m == 08 || m == 10 || m == 12) {
var dmax = 31;
return dmax;
}
else if (m == 04 || m == 06 || m == 09 || m == 11) {
var dmax = 30;
return dmax;
}
else {
if ((y % 400 == 0) || (y % 400 == 0 && y % 100 != 0)) {
dmax = 29;
return dmax;
}
else {
dmax = 28;
}
return dmax;
}
}

Place of calling:
<asp:DropDownList ID="ddDay" runat="server" Onclick="return AddItem();">
shreshtha
 
Posts: 1
Joined: Fri Sep 17, 2010 7:08 am

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests