<table width="200"><tr><th><!-- <bt> --> календарь <!-- </bt> --></th></tr> <tr><td class="colorborder"><div align="center"><!-- <bc> --> <table width="100%" height="190" border='0' align="center"><tr> <td style="vtical-align: middle; text-align: center;"> <table style="text-align: left;" align="center"> <tr><td align="center"> <div id="v33calendarTitle"></div> </td></tr><tr><td> <div id="v33calendarTalk"></div> </td></tr><tr><td align="center"> <input type="button" value="дата" onclick="ver3ClickWav()"> </td></tr> </table> <script> function v33createCalendar(v33elem, v33year, v33month, v33day) { let v33mon = v33month - 1; // месяцы в JS идут от 0 до 11, а не от 1 до 12 let v33data = new Date(v33year, v33mon); let v33table = '<table><tr><th>пн</th><th>вт</th><th>ср</th><th>чт</th><th>пт</th> <th>сб</th><th>вс</th></tr><tr>'; // пробелы для первого ряда // с понедельника до первого дня месяца // * * * 1 2 3 4 for (let i = 0; i < getDay(v33data); i++) { v33table += '<td></td>'; } // <td> ячейки календаря с датами while (v33data.getMonth() == v33mon) { v33table += '<td'; if (v33data.getDate() == v33day) v33table += ' style="background-color: rgb(51, 204, 255);"'; if (getDay(v33data) % 7 == 5) v33table += ' style="background-color: rgb(255, 204, 204);"'; if (getDay(v33data) % 7 == 6) v33table += ' style="background-color: rgb(255, 204, 204);"'; if (v33data.getDate() === 8) {if (v33data.getMonth() === 2) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 9) {if (v33data.getMonth() === 4) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 1) {if (v33data.getMonth() === 4) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 23) {if (v33data.getMonth() === 1) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 1) {if (v33data.getMonth() === 0) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 2) {if (v33data.getMonth() === 0) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 3) {if (v33data.getMonth() === 0) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 4) {if (v33data.getMonth() === 0) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 5) {if (v33data.getMonth() === 0) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 7) {if (v33data.getMonth() === 0) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 4) {if (v33data.getMonth() === 10) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 7) {if (v33data.getMonth() === 10) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 12) {if (v33data.getMonth() === 5) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; if (v33data.getDate() === 12) {if (v33data.getMonth() === 11) { v33table += ' style="background-color: rgb(255, 204, 204);"';}}; v33table += '>'; v33table += v33data.getDate(); v33table += '</td>'; if (getDay(v33data) % 7 == 6) { // вс, последний день - перевод строки v33table += '</tr><tr>'; } v33data.setDate(v33data.getDate() + 1); } // добить таблицу пустыми ячейками, если нужно // 29 30 31 * * * * if (getDay(v33data) != 0) { for (let i = getDay(v33data); i < 7; i++) { v33table += '<td></td>'; } } // закрыть таблицу v33table += '</tr></table>'; v33elem.innerHTML = v33table; } function getDay(date) { // получить номер дня недели, от 0 (пн) до 6 (вс) let day = date.getDay(); if (day == 0) day = 7; // сделать воскресенье (0) последним днем return day - 1; } var v33segodn = new Date(); document.getElementById('v33calendarTitle').innerHTML = v33segodn.toLocaleString('ru', {month: 'long'}); v33createCalendar(v33calendarTalk, v33segodn.getFullYear(), v33segodn.getMonth()+1, v33segodn.getDate()); </script> </td></tr></table> <!-- </bc> --></div></td></tr></table>