SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Birthday dropdown

    Hmmm, I've been looking all over for this code that I guess is used a lot.
    I have a from where user will register and I want them to fill in their birthday using three dropdowns.

    The first one, called year, I would like to be from this year and then back 100 years.
    The next one called month and the last one day.

    I guess it would be easy to find this code online, but since I'm not used to the language (I'm from Sweden). I just don't know what to look for and what it's called. Haven't found it yet.

    So, if anyone have a link or just a code that I can use for this simple thing (I guess it's pretty simple), but I just can't figure out how to do it.

  2. #2
    SitePoint Member
    Join Date
    May 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
        
    echo '<select name="year">';
          echo 
    '<option></option>';
            for(
    $i date('Y'); $i >= date('Y'strtotime('-100 years')); $i--){
              echo 
    "<option value='$i'>$i</option>";
            } 
        echo 
    '</select>/';
        echo 
    '<select name="month">';
            echo 
    '<option></option>';
            for(
    $i 1$i <= 12$i++){
              
    $i str_pad($i20STR_PAD_LEFT);
                echo 
    "<option value='$i'>$i</option>";
            }
        echo 
    '</select>/';
        echo 
    '<select name="day">';
          echo 
    '<option></option>';
            for(
    $i 1$i <= 31$i++){
              
    $i str_pad($i20STR_PAD_LEFT);
                echo 
    "<option value='$i'>$i</option>";
            }
        echo 
    '</select>';
    ?>

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot. That is just what I was looking for. Now I can continue with the rest of the form and functions.

    Thank you.


Bookmarks

Posting Permissions

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