Advertisement
Sempervivum

Untitled

Feb 11th, 2017
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None
  1. <select id="terminauswahl">
  2. <option></option>
  3. <option></option>
  4. <option></option>
  5. <option></option>
  6. <option></option>
  7. </select>
  8. <script>
  9. function myParseDate(rows, rowIdx) {
  10. var datearr = rows[rowIdx].cells[1].innerHTML.split(".");
  11. var timearr = rows[rowIdx].cells[2].innerHTML.split(":");
  12. return new Date(parseInt(datearr[2]), parseInt(datearr[1]) - 1, parseInt(datearr[0]),
  13. parseInt(timearr[1]), parseInt(timearr[0]), 0);
  14. }
  15. var now = new Date().getTime();
  16. var rows = document.getElementById("termine").rows;
  17. var nextTime = new Date(2099, 0, 1).getTime();
  18. var rowIdx = 1;
  19. for (var i = 1; i < rows.length; i++) {
  20. var currentTime = myParseDate(rows, i).getTime();
  21. if (currentTime < nextTime && currentTime > now) {
  22. rowIdx = i;
  23. nextTime = currentTime;
  24. }
  25. }
  26. console.log(rowIdx);
  27. rows[rowIdx].style.backgroundColor = "lightblue";
  28. rows[rowIdx].style.border = "thin solid blue";
  29. document.getElementById("sThema").innerHTML = rows[rowIdx].cells[0].innerHTML;
  30. document.getElementById("sDatum").innerHTML = rows[rowIdx].cells[1].innerHTML;
  31. document.getElementById("sUhrzeit").innerHTML = rows[rowIdx].cells[2].innerHTML;
  32. document.getElementById("sOrt").innerHTML = rows[rowIdx].cells[3].innerHTML;
  33. var terminauswahl = document.getElementById("terminauswahl");
  34. for (var i = 0; i < rows.length; i++) {
  35. var time = rows[i].cells[1].innerHTML + " " + rows[i].cells[2].innerHTML;
  36. terminauswahl.options[i].value = time;
  37. terminauswahl.options[i].innerHTML = time;
  38. }
Advertisement
RAW Paste Data Copied
Advertisement