www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Drop Down Box Help

  1. #1
    Join Date
    Feb 2006
    Posts
    193

    resolved [RESOLVED] Drop Down Box Help

    Hello:

    I have a script which contains a drop down boxes for month, day, year and location.

    When the person clicks submit another script processes the form. In this script, I would like to show the name of the month not the numeric value of the month. When I display the date, I get 112007. I would like to show 'January" rather than "1" and I would like the date to display as January 1, 2007.

    My question is how do I use the label from the drop down box for month so the name of the month appears? Also, how do I format this date?

    Here is how the drop down boxes appear:
    PHP Code:
    <?php
              $months 
    = array (=> 'January''February''March''April''May''June''July''August',
                    
    'September''October''November''December');

                
    //Make the days and years arrays

               
    $days range (1,31);
               
    $years range (20072015);

               
    //Make the months pull-down menu

               
    echo '<select name="month">';
               foreach (
    $months as $key => $value) {
               echo 
    "<option value=\"$key\">$value</option>\n";
                  }
               echo 
    '</select>';

               
    //Make the days pull-down menu

               
    echo '<select name="day">';
               for (
    $day 1$day <= 31$day++) {
               echo 
    "<option value=\"$day\">$day</option>\n";
                }
               echo 
    '</select>';

              
    //Make the years pull down menu

              
    echo '<select name="year">';
              
    $year 2007;
              while (
    $year <= 2015) {
              echo 
    "<option value=\"$year\">$year</option>\n";
              
    $year++;
                }
              echo 
    '</select>';

    ?>
        </td></tr>
    <tr><td><b>Property Location:</b></td><td>&nbsp;</td>
        <td><select name="location" size=1>
            <option value=GA>Georgia</option></select></td></tr>
    This is the portion of the script which displays the date:
    PHP Code:
    <tr><td><b>Planned Closing Date:</b></td><td>&nbsp;&nbsp;</td><td><?php echo $_SESSION['month'] . $_SESSION['day'] . $_SESSION['year']; ?></td></tr>
    Can someone help me out?
    Thanks.

  2. #2
    Join Date
    Jun 2006
    Location
    Down at the bottom of the garden
    Posts
    1,239
    PHP Code:
    <?php
    $date 
    date("F j, Y"mktime(000$_SESSION['month'], $_SESSION['day'], $_SESSION['year']));
    ?>
    <tr><td><b>Planned Closing Date:</b></td><td>&nbsp;&nbsp;</td><td><?php echo $date?></td></tr>

  3. #3
    Join Date
    Feb 2006
    Posts
    193
    Thank you, that worked perfectly.

  4. #4
    Join Date
    Jun 2006
    Location
    Down at the bottom of the garden
    Posts
    1,239
    Glad I could help!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles