Page 1 of 1
showing current and next 5 months in combo box
Posted: Wed Oct 28, 2009 5:43 am
by ranjitbd
Code: Select all
// i want to show dynamically 6 months including current month in a combo box.
// like when October will be over combo box will show November to April.
// please help me..code can be in php or javascript....
Re: showing current and next 5 months in combo box
Posted: Wed Oct 28, 2009 7:52 am
by Mark Baker
This logic may help:
Code: Select all
$month = mktime();
echo date('M',$month).'<br />';
for($i = 0; $i < 5; $i++) {
$month = strtotime(date('d-M-Y',$month).' + 1 Month');
echo date('M',$month).'<br />';
}
Re: showing current and next 5 months in combo box
Posted: Thu Nov 05, 2009 4:49 am
by ranjitbd
Mark Baker wrote:This logic may help:
Code: Select all
$month = mktime();
echo date('M',$month).'<br />';
for($i = 0; $i < 5; $i++) {
$month = strtotime(date('d-M-Y',$month).' + 1 Month');
echo date('M',$month).'<br />';
}
Code: Select all
// your code is nice but i have to implement within a combo box
// so what to do?
<select name="month" id="month">
// any condition for showing six month
<?php for($i=1; $i<=6; $i++){?>
<option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php } ?>
</select>