Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
166
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div width="100" border="1" cellpadding="0" cellspacing="1" id="wrtabelle1"></div>
  2. <script>
  3. xVar = 10;
  4. yVar = 10;
  5. function start(row, col) {
  6. node = document.getElementById("wrtabelle1");
  7. node.appendChild(createTable(row, col, "tabelle1"), node);
  8. }
  9. function random() {
  10. return Math.floor((Math.random() * 998) + 1);
  11. }
  12. function createTable(row, col, id) {
  13.  
  14. var myTable = document.createElement("table");
  15. var mytablebody = document.createElement("tbody");
  16.  
  17. for (var j = 0; j < row; j++) {
  18. mycurrent_row = document.createElement("tr");
  19. for (var i = 0; i < col; i++) {
  20. mycurrent_cell = document.createElement("td");
  21. mycurrent_cell.addEventListener("click", function (iii, jjj) {
  22. return function () {
  23. if (!myTable.getAttribute("data-locked"))
  24. console.log(this.innerHTML, iii, jjj);
  25. if (this.innerHTML != "700") myTable.setAttribute("data-locked", "true");
  26. }
  27. }(i, j));
  28. currenttext = document.createTextNode(random());
  29. mycurrent_cell.appendChild(currenttext);
  30. mycurrent_row.appendChild(mycurrent_cell);
  31. }
  32.  
  33. mytablebody.appendChild(mycurrent_row);
  34. }
  35.  
  36. myTable.appendChild(mytablebody);
  37. myTable.setAttribute("ID", id);
  38. return myTable;
  39. }
  40. start(xVar, yVar);
  41. </script>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement