== drop downs [days][month][year] that behave ==
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   joey_corleon
Posted On:   Monday, February 17, 2003 11:15 AM

Hi


As you must all know, the months of the year have not the same amount of days (some have 30, some 31, some 28 ... plus the leap day from time to time).


Does anyone have the code (or some sort of hint) to create the following SELECTs :-
[day][month][year]


In which [day] is dynamically modified (from 1to30 or 1to31 .etc...) depending on the two other fields?


I presume the "onClick" even on [month] and [year] is used to do so ... but I am not a developer myself :o((((


Any help rewarded by a virtual handcheck :o)


Joey-

Re: == drop downs [days][month][year] that behave ==

Posted By:   Nitesh_Naveen  
Posted On:   Tuesday, February 18, 2003 01:56 AM

See this link (click here). You need to have a month array as in this faq. In addition you need to create a days array specifying the no. of days in each month. You can use this function as a reference on how to populate the select box

// Function to populate the given combo box with elements from a javascript array
// Accepts the following arguments:
// The combo/select object to be populated
// The array of elements to be populated
// Whether the combo is to be empties before populating.
// Returns : none
function populateCombo(comboObj,elements,shouldEmpty)
{
if(shouldEmpty)
comboObj.options.length = 0;
for(srcSelCount=0;srcSelCount {
if(elements[srcSelCount] == "")
continue;
len = comboObj.options.length;
comboObj.options.length = len+1;
comboObj.options[len].text = elements[srcSelCount];
}
}

You should use the onchange of the months and year combo. in the onchage of year combo you have to change the days array corresponding to February. in onchange of months combo you need to repopulate the days combo.
About | Sitemap | Contact