I have been trying to display a table when a user select a data from the datepicker and display a table with the number of columns equal to the number of days to the select month.
However, I have 2 issues and I am not sure I to fix them...
- The datapicker although when selected a specific month, it actually display the previous month instead (ie. selected April, it shows March).
- Portions of the table is shown, is there a way to hide them before a month is selected?
Here is the link to the script I am writing.
Here is the code for generating the table...
However, I have 2 issues and I am not sure I to fix them...
- The datapicker although when selected a specific month, it actually display the previous month instead (ie. selected April, it shows March).
- Portions of the table is shown, is there a way to hide them before a month is selected?
Here is the link to the script I am writing.
Here is the code for generating the table...
PHP:
<div class="pull-right form-inline" style="margin-bottom:10px;">
<div class="form-group">
<div class='input-group date' id='m_picker'>
<div class="form-control"><?=!empty($selected_month)?date('Y / m',$selected_time):'Select Month'?></div>
<input type='hidden' value="<?=!empty($selected_month)?date('Y-m',$selected_time):''?>" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<table id="table2" width="100%" style="margin-top: 10px;">
<tbody>
<tr>
<td class="text-right">Date</td>
<? for ($d = 1; $d <= $days; $d++)
echo "<td colspan=\"2\" class=\"text-center\">{$d}</td>"; ?>
</tr>
<tr>
<td class="text-center">Group</td>
<? for ($d = 1; $d <= $days; $d++) {
echo "<td class=\"text-center\">Hours</td>
<td class=\"text-center\">Number</td>"; }?>
</tr>
<? for ($i = 1; $i <= 10; $i++) {
echo "<tr>
<td class=\"text-center\">name</td>";
for ($d = 1; $d <= $days; $d++) {
echo "<td class=\"text-right text-blue\">num1</td>
<td class=\"text-right text-red\">num2</td>"; }
echo "</tr>";} ?>
<tr>
<td class="text-center"></td>
<? for ($d = 1; $d <= $days; $d++) {
echo "<td class=\"text-right\">num1</td>
<td class=\"text-right\">num2</td>";} ?>
</tr>
</tbody>
</table>
<script type="text/javascript">
var test;
$(function () {
$('#m_picker').datetimepicker({
format: 'YYYY / MM',
viewMode: 'months'
});
$('#m_picker').on('dp.hide', function(e){
$('#m_picker>div.form-control').text($('#m_picker>input').val());
var select_date = e.date._d;
var month=Math.floor(new Date(select_date).getTime()/1000);
location.href='_tablework.php?m='+ month;
});
});
</script>