12-21-2015, 01:52 AM
(This post was last modified: 12-21-2015, 05:04 AM by wolfgang1983.)
Currently on my modal form. I have 2 select drop down's.
Called year, month.
At the moment for the day I have to type it in.
What I would like to know is how am so that when I select a month it will populate the select day div with the correct number of days because some months shorter than others?
Called year, month.
At the moment for the day I have to type it in.
What I would like to know is how am so that when I select a month it will populate the select day div with the correct number of days because some months shorter than others?
PHP Code:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<?php echo form_open('dashboard/calendar');?>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Add Calendar Event</h4>
</div>
<div class="modal-body">
<div class="form-group">
<select name="year" class="form-control">
<?php
$cur_year = date('Y');
for($year = ($cur_year-10); $year <= ($cur_year+10); $year++) {
if ($year == $cur_year) {
echo '<option value="'.$year.'" selected="selected">'.$year.'</option>';
} else {
echo '<option value="'.$year.'">'.$year.'</option>';
}
}
?>
<select>
</div>
<div class="form-group">
<select name="month" class="form-control">
<?php
$monthName = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
for ($i=0; $i < count($monthName); $i++) {
$mn = 1 + $i;
if($mn == date('m')) {
echo '<option selected value=' . $mn . '>' . $monthName[$i] . '</option>';
} else {
echo '<option value=' . $mn . '>' . $monthName[$i] . '</option>';
}
}
?>
</select>
</div>
<!--
I currently have to enter day in mannually
<div class="form-group">
<select name="day" class="form-control"></select>
</div>
-->
<div class="form-group">
<input type="text" name="day" class="form-control" placeholder="Enter Day" value="" />
</div>
<div class="form-group">
<textarea name="event" rows="5" class="form-control"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="submit" name="save" class="btn btn-primary" value="Save" />
</div>
</div>
<?php echo form_close();?>
</div>
</div>
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!