I've a dropdown list Year
made in php with years from current year until current year+10:
<p>Year:
<select name="sel_year">
<?php
$year=date("Y")-1;
for ($i = 0; $i <= 10; $i++)
{
$year = $year+1;
echo("<option value=\"$year\">$year</option>");
}
?>
</select>
And i want to make a second dropdown list with months
that are based on the selection made on the previous list (Year
), the thing is that i can only use html and php and i need to do this on the same page and, if possible, without using a submit button.
This is what i've so far:
<p>Month:
<select name="sel_month">
<?php
if(sel_year==(date("Y")))
{
for ($month = date("m"); $month <= 12; $month++)
{
$monthName = date('F', mktime(0, 0, 0, $month, 10));
echo("<option value=\"$month\">$monthName</option>");
}
}
?>
</select>
In this part I only want to allow to user to select the months from now until December (inclusive) if the selected year previously is the same year as we're in. Any ideas?