I'm trying to make some sort of "timesheet" where the user inputs 2 dates
and it calculates each month/year and display on a combobox.
I wanted to DYNAMICALLY(no need to refresh the page or anything) update the amount of days and fill the table with Day Number
and Day Name(monday,etc..)
I managed to calculate the amount of days in a month but how can I display my table without reload the page?
Maybe I should use JSON arrays with Ajax? But how do I achive this?
JavaScript
$(document).ready(function() {
$('#dates').change(function() {
var splitDate = $('#dates').val().split("/");
var month = splitDate[0];
var year = splitDate[1];
var days = daysInMonth(month,year);
alert(days);
});
function daysInMonth(month,year) {
return new Date(year, month, 0).getDate();
}
});
HTML
<div class="row" style="margin-top: 30px;">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th class="text-center">#</th>
<th class="text-center">Day</th>
<th class="text-center">Number of Clients</th>
<th class="text-center"></th>
</tr>
</thead>
<tbody>
<tr class="text-center">
<td></td>
<td></td>
<td><input name="amountOfClients[]" type="number"></td>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</div>