I have a "search by month and year " feature and have listed the months and year in a drop-down (select) field.so far this is working perfect but i need to show selected (month and year) after submitting the form .but i unable to do how to get selected year and month in drop down.below is my php JavaScript code .anyone help me how to solve
below is the two dropdowns for month year .the month and year sholud be shown as selected.
<select name="month" class="form-control" >
<?php
for ($i = 0; $i <= 12; ++$i)
{
$time = strtotime(sprintf('+%d months', $i));
$label = date('F ', $time);
$value = date('m', $time);
printf('<option value="%s" selected="selected">%s</option>', $value, $label);
}
?>
</select>
<select name="year" class="form-control">
<?php
for ($i = 0; $i <= 12; ++$i)
{
$time = strtotime(sprintf('-%d years', $i));
$value = date('Y', $time);
$label = date('Y ', $time);
printf('<option value="%s" selected="selected">%s</option>', $value, $label);
}
?>
</select>
so far this is working perfect but i need to show selected (month and year) after submitting the form .but i unable to do how to get selected year and month in drop down.below is my php java-script code .anyone help me how to solve it?