Advertisement
Sempervivum

Untitled

Feb 17th, 2017
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None
  1. <style>
  2. #termine {
  3. border-collapse: collapse;
  4. }
  5.  
  6. select {
  7. margin: 10% 10% 0% 10%;
  8. width: 70%;
  9. padding: 5%;
  10. padding-right: auto;
  11. padding-left: auto;
  12. display: block;
  13. }
  14. #wrtermine {
  15. overflow: hidden;
  16. display: none;
  17. }
  18. </style>
  19.  
  20. <button id="btntermine">Termine anzeigen/verstecken</button>
  21. <div id="wrtermine">
  22. <table id="termine">
  23. <thead>
  24. <tr>
  25. <th><strong>Thema</strong></th>
  26. <th><strong>Datum</strong></th>
  27. <th><strong>Uhrzeit</strong></th>
  28. <th><strong>Ort</strong></th>
  29. </tr>
  30. </thead>
  31. <tbody>
  32. <tr>
  33. <td>Beispiel</td>
  34. <td id="Datum1">21.12.2016</td>
  35. <td>12:15</td>
  36. <td>Kursort 1</td>
  37. </tr>
  38. <tr class="zweitezeile">
  39. <td>Beispiel</td>
  40. <td id="Datum2">15.12.2016</td>
  41. <td>13:45</td>
  42. <td>Kursort 2</td>
  43. </tr>
  44. <tr>
  45. <td>Beispiel</td>
  46. <td id="Datum3">04.01.2017</td>
  47. <td>12:15</td>
  48. <td>Kursort 1</td>
  49. </tr>
  50. <tr class="zweitezeile">
  51. <td>Beispiel</td>
  52. <td id="Datum4">03.03.2016</td>
  53. <td>12:15</td>
  54. <td>Kursort 2</td>
  55. </tr>
  56. <tr>
  57. <td>Beispiel</td>
  58. <td id="Datum5">05.01.2017</td>
  59. <td>12:15</td>
  60. <td>Kursort 1</td>
  61. </tr>
  62. </tbody>
  63. </table>
  64. </div>
  65.  
  66. <div id="sidebar">
  67. <h4>Neue Termine:</h4>
  68. <table id="sidebartabelle">
  69. <tr>
  70. <td id="sThema">Soul Movements</td>
  71. </tr>
  72. <tr class="zweitezeile">
  73. <td id="sDatum">15.11.2017</td>
  74. </tr>
  75. <tr>
  76. <td id="sUhrzeit">12:35</td>
  77. </tr>
  78. <tr class="zweitezeile">
  79. <td id="sOrt">Kursort 2</td>
  80. </tr>
  81. </table>
  82. </div>
  83. <h3 id="Anmeldung">Anmeldung:</h3>
  84. <form>
  85. <input type="name" placeholder="Name" required>
  86. <input type="name" placeholder="Vorname" required>
  87. <select id="terminauswahl"></select>
  88. <input type="email" placeholder="E-Mail" required>
  89. <input type="submit" placeholder="Senden" id="ud_send">
  90. </form>
  91. <script>
  92. $("#btntermine").on("click", function () {
  93. $("#wrtermine").slideToggle(500);
  94. });
  95. function myParseDate(rows, rowIdx) {
  96. var datearr = rows[rowIdx].cells[1].innerHTML.split(".");
  97. var timearr = rows[rowIdx].cells[2].innerHTML.split(":");
  98. return new Date(parseInt(datearr[2]), parseInt(datearr[1]) - 1, parseInt(datearr[0]), parseInt(timearr[0]), parseInt(timearr[1]), 0);
  99. }
  100. var now = new Date().getTime();
  101. var rows = document.getElementById("termine").rows;
  102. var nextTime = new Date(2099, 0, 1).getTime();
  103. var rowIdx = -1;
  104. for (var i = 1; i < rows.length; i++) {
  105. var currentTime = myParseDate(rows, i).getTime();
  106. if (currentTime < nextTime && currentTime > now) {
  107. rowIdx = i;
  108. nextTime = currentTime;
  109. }
  110. }
  111. console.log(rowIdx);
  112. if (rowIdx != -1) {
  113. rows[rowIdx].style.backgroundColor = "mistyrose";
  114. rows[rowIdx].style.border = "thin solid red";
  115. }
  116.  
  117. document.getElementById("sThema").innerHTML = rows[rowIdx].cells[0].innerHTML;
  118. document.getElementById("sDatum").innerHTML = rows[rowIdx].cells[1].innerHTML;
  119. document.getElementById("sUhrzeit").innerHTML = rows[rowIdx].cells[2].innerHTML;
  120. document.getElementById("sOrt").innerHTML = rows[rowIdx].cells[3].innerHTML;
  121.  
  122. var terminauswahl = document.getElementById("terminauswahl");
  123. terminauswahl.innerHTML = "";
  124. for (var i = 0; i < rows.length; i++) {
  125. var currentTime = myParseDate(rows, i).getTime();
  126. if (currentTime > now || i == 0) {
  127. var timeStr = rows[i].cells[1].innerHTML + " " + rows[i].cells[2].innerHTML;
  128. var opt = document.createElement("option");
  129. opt.value = timeStr;
  130. opt.innerHTML = timeStr;
  131. terminauswahl.appendChild(opt);
  132. }
  133. }
  134.  
  135. var params = {
  136. sThema: rows[rowIdx].cells[0].innerHTML,
  137. sDatum: rows[rowIdx].cells[1].innerHTML,
  138. sUhrzeit: rows[rowIdx].cells[2].innerHTML,
  139. sOrt: rows[rowIdx].cells[3].innerHTML
  140. };
  141. $.post("sidebar-schreiben.php", params, function (data) {
  142. var s = data;
  143. });
  144.  
  145. </script>
Advertisement
RAW Paste Data Copied
Advertisement