Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a web page that contains three drop down menu that display month, day and

ID: 3684056 • Letter: C

Question

Create a web page that contains three drop down menu that display month, day and year. Call this php page as php-drop-down-date.php

For example to create drop down menu using PhP script, you may use the following.

print " <option value="$day">$day</option>";

} print '</select>';

The above script will generate an equivalent html counterpart as below

The year drop down menu can be created similarly. The month may need to use other mean. Check the internet to find an appropriate solution. (You may use array to hold the months)

Explanation / Answer

<?PHP
    FUNCTION ShowDate()
    {
        /* create array so we can name months */
        $monthName = ARRAY(1=> "January", "February", "March",
            "April", "May", "June", "July", "August",
            "September", "October", "November", "December");
         print '<select name="month">';
for ($month = 1; $month<= 12; $month++) {
                      print " <option value="$monthName[$month]">$monthName[$month]</option>";
             } print '</select>'; /* make month selector */
       
        /* make day selector */
print '<select name="day">';
for ($day = 1; $day <= 31; $day++) {
                      print " <option value="$day">$day</option>";
             } print '</select>';

        /* make year selector */
print '<select name="year">';
for ($year = 1990; $year <= 2016; $year++) {
                      print " <option value="$year">$year</option>";
             } print '</select>';

     }
?>

<HTML>
<HEAD>
<TITLE> Date Demo </TITLE>
</HEAD>
<BODY>
<FORM name=frm>
Choose a Date: <?PHP ShowDate(); ?>
</FORM>
</BODY>
</HTML>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote