drop downs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bgruha
    New Member
    • May 2007
    • 3

    drop downs

    HI
    I have three drop downs.One for years(say ddlYear),one for months(say ddlMon) and the last one for no.of days(say ddlDays)
    'ddlYear' dropdown is populated with years from 1900 to 2100.
    'ddlMon' drop down is pouplated with months.
    When i select year and month from ddlYear and ddlMon, i wan the drop down ddlDays to be populated with corresponding no.of days.
    (Including the case of leap year also)
    Can anyone help me to get this...using javascript


    Thanks in advance
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    What have you managed so far?

    The days would be at least 28. You can add and delete the last 1, 2 or 3 options depending on the month and year.

    Use the Date object to determine the days. You can do this by setting the date to the 31st. The date will automatically roll over to the next month if the month has less than 31 days. From that, you can determine the number of days in the current month. This is if you want to do it automatically for every month, otherwise you could easily check manually for each month. April, June, September and November have 30. The rest 31, expect February. For February, you should use the above method. If the date changes to the 3rd of March, you know there's 28 days and if it's the 2nd of March there are 29 days in that year.

    To add/delete options, see link

    Comment

    • mrhoo
      Contributor
      • Jun 2006
      • 428

      #3
      Call the date adjuster code acoder described with the date select element's onfocus event, or the onchange events of both the year and month selects.

      Comment

      Working...