Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <!--
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
- -->
- <html>
- <head>
- <title>TODO supply a title</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- </head>
- <body>
- <select id="miesiac">
- <option value="0">Styczeń</option>
- <option value="1">Luty</option>
- <option value="2">Marzec</option>
- <option value="3">Kwiecień</option>
- <option value="4">Maj</option>
- <option value="5">Czerwiec</option>
- <option value="6">Lipiec</option>
- <option value="7">Sierpień</option>
- <option value="8">Wrzesień</option>
- <option value="9">Październik</option>
- <option value="10">Listopad</option>
- <option value="11">Grudzień</option>
- </select>
- <input id="year" min="2018" max="2019" type="number">
- <input type="button" value="Pokaż" onclick="calendar()">
- <p id="cal"></p>
- <script>
- var tab = ['pon', 'wt', 'śr', 'czw', 'pt', 'sob', 'ndz'];
- function calendar()
- {
- var month = document.getElementById('miesiac').value;
- var year = document.getElementById('year').value;
- t = new Date(year, month, 1);
- var m = t.getMonth();
- if(m+1 == 12) m = -1;
- console.log(m);
- t.getDay();
- t = new Date(t.getTime()-(t.getDay()-1)*24*60*60*1000);
- //document.write(t);
- var html = "<table>";
- html = html + "<tr>";
- for(i=0; i<tab.length; i++)
- {
- html = html + "<td>" + tab[i] + "</td>";
- }
- html = html + "</tr>";
- while(t.getMonth() != m+1)
- {
- console.log(t.getMonth())
- html = html + "<tr>";
- for(let i=0; i<7; i++)
- {
- html = html + "<td>" + t.getDate() + "</td>";
- t = new Date(t.getTime()+24*60*60*1000);
- }
- html = html + "</tr>";
- }
- html = html + "</html>";
- var p = document.getElementById('cal');
- cal.innerHTML = html;
- //document.write(html);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement