Converting a Textbox into a Dropdownlist of DD-MM-YY

Posted on 2006-05-21
Last Modified: 2008-03-06

Currently i use a textbox to get input of date ->
<input id="date" name="date" ...> Format: 2006-01-31

How do i change this into 3 comboboxes of YYYY - MM - , populated with date values
and auto converts it into a string
Question by:jedistar
    LVL 16

    Accepted Solution

    if (isset($_POST['day'])){
          echo $date;

    <form actio='' method="POST">
    <select name="day">
    for ($i=1;$i<32;$i++) echo "<option vlaue='$i'>$i</option>";?>
    <select name="month">
    for ($i=1;$i<13;$i++) echo "<option vlaue='$i'>$i</option>";?>
    <select name="year">
    for ($i=1990;$i<2011;$i++) echo "<option vlaue='$i'>$i</option>";?>
    <input type="submit">
    LVL 5

    Assisted Solution

    $date = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now