I created a javascript function that assembles a calendar. I need this schedule to work according to the number and days of the week of the given month. Ex ( August 1st fell on a Tuesday ). I also need that when I change the month my schedule will mount according to the selected month. Follow the code.
Function that mounts my calendar
$(document).ready(function () {
var str = '';
var aux = 1;
var tr = '';
var tbl = $('#calendar');
for (var i = 1; i < 32; i++) {
if (aux == 1) {
tr = '<tr>';
}
str += tr + '<td class="calendario btnExibirDetalhes" data-toggle="modal" data-target="#Modal" position="static">' + i + '</td>';
if (aux == 7) {
str = str + tr;
aux = 0;
}
aux++;
tr = '';
}
if (tr == '') {
tr = '</tr>';
str = str + tr
}
tbl.append(str);
});
Function that arrows the current month
$(document).ready(function () {
monName = new Array("Janeiro",
"Fevereiro",
"Março",
"Abril",
"Maio",
"Junho",
"Julho",
"Agosto",
"Setembro",
"Outubro",
"Novembro",
"Dezembro")
hoje = new Date();
var preenchemes = $('#mes');
preenchemes.append(monName[hoje.getMonth()]);
});