Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Drop Down Menu?

    Hi,

    I am looking for some code that will list the Day, month, year in seperate drop down menus, I want the day menu to limit the day depending on the month, For example some months have 31 days some have 28 and some have 30??

    Any Ideas?

    Thanks,

    Matt

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You mean you want one drop down box for days, one for months and one for years and you want the days options to dynamically change depending what the user selects in the months box? If so, you'd be better off getting the data from PHP but then writing the actual script in javascript, since PHP won't be able to change the number of days in the days drop down menu without a page refresh.

    Getting the actual data is easy with PHP, using the many options available with the date() function. For instance, date("t", mktime (0,0,0,$month,1,$year)); will tell you exactly how many days there are in the month "$month" during the year "$year". You just need to output the data as arrays or something that your javascript can use to create the dynamic drop-downs.


  •  

    Posting Permissions

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