Example #1
0
        echo ">{$day}</option>\n";
    }
    echo '</select>';
    // 创建年份下拉菜单
    echo '<select name="year">';
    for ($year = 2005; $year <= 2015; $year++) {
        echo "<option value=\"{$year}\"";
        if ($year == $y) {
            // Preselect.
            echo ' selected="selected"';
        }
        echo ">{$year}</option>\n";
    }
    echo '</select>';
}
// 函数定义结束
// Create the form tags.
echo '<h1 id="mainhead">选择一个日期</h1>
<p><br /></p><form action="dateform.php" method="post">';
// Get today's information and call the function.
$dates = getdate();
make_calendar_pulldowns($dates['mon'], $dates['mday'], $dates['year']);
echo '&nbsp;&nbsp;<input name="submit" type="submit" value="提交" />';
echo '</form><p><br /></p>';
// End of form.
if (!empty($_POST['submit'])) {
    echo '<p>您选择了 ' . $_POST['year'] . '年' . $_POST['month'] . '月' . $_POST['day'] . '日</p>';
} else {
    echo '<p>今天是 ' . date('l') . ',现在时间为: ' . date('g:i a') . '.</p>';
}
include './includes/footer.html';
Example #2
0
include "includes/header.html";
// This function makes three pull-down menus
// for selecting a month, day and year
function make_calendar_pulldowns()
{
    // Make months array and months pull-down menu
    $months = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December");
    echo '<select name="month">';
    foreach ($months as $key => $value) {
        echo "<option value=\"{$key}\">{$value}</option>\n";
    }
    echo '</select>';
    // Make days pull-down menu
    echo '<select name="day">';
    for ($day = 1; $day <= 31; $day++) {
        echo "<option value=\"{$day}\">{$day}</option>\n";
    }
    echo '</select>';
    // Make years pull-down menu
    echo '<select name="year">';
    for ($year = 2008; $year <= 2018; $year++) {
        echo "<option value=\"{$year}\">{$year}</option>\n";
    }
    echo '</select>';
}
// Create form tags
echo '<h1>Select a date</h1><form action="dateform.php" method="post">';
// Call the function
make_calendar_pulldowns();
echo '</form>';
include "includes/footer.html";