Advertisement
Guest User

aaaaaaa

a guest
Nov 21st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8. <head>
  9. <title>TODO supply a title</title>
  10. <meta charset="UTF-8">
  11. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  12. </head>
  13. <body>
  14. <select id="miesiac">
  15. <option value="0">Styczeń</option>
  16. <option value="1">Luty</option>
  17. <option value="2">Marzec</option>
  18. <option value="3">Kwiecień</option>
  19. <option value="4">Maj</option>
  20. <option value="5">Czerwiec</option>
  21. <option value="6">Lipiec</option>
  22. <option value="7">Sierpień</option>
  23. <option value="8">Wrzesień</option>
  24. <option value="9">Październik</option>
  25. <option value="10">Listopad</option>
  26. <option value="11">Grudzień</option>
  27. </select>
  28. <input id="year" min="2018" max="2019" type="number">
  29. <input type="button" value="Pokaż" onclick="calendar()">
  30. <p id="cal"></p>
  31. <script>
  32. var tab = ['pon', 'wt', 'śr', 'czw', 'pt', 'sob', 'ndz'];
  33. function calendar()
  34. {
  35. var month = document.getElementById('miesiac').value;
  36. var year = document.getElementById('year').value;
  37. t = new Date(year, month, 1);
  38.  
  39. var m = t.getMonth();
  40. if(m+1 == 12) m = -1;
  41. console.log(m);
  42.  
  43. t.getDay();
  44. t = new Date(t.getTime()-(t.getDay()-1)*24*60*60*1000);
  45. //document.write(t);
  46.  
  47. var html = "<table>";
  48. html = html + "<tr>";
  49. for(i=0; i<tab.length; i++)
  50. {
  51. html = html + "<td>" + tab[i] + "</td>";
  52. }
  53. html = html + "</tr>";
  54.  
  55. while(t.getMonth() != m+1)
  56. {
  57. console.log(t.getMonth())
  58. html = html + "<tr>";
  59. for(let i=0; i<7; i++)
  60. {
  61. html = html + "<td>" + t.getDate() + "</td>";
  62. t = new Date(t.getTime()+24*60*60*1000);
  63. }
  64. html = html + "</tr>";
  65. }
  66. html = html + "</html>";
  67. var p = document.getElementById('cal');
  68. cal.innerHTML = html;
  69. //document.write(html);
  70. }
  71. </script>
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement