Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Untitled</title>
  5. <style type="text/css">
  6. table{
  7. border-collapse:collapse;
  8. }
  9. td{
  10. border: 1px solid rgb(0,0,0);
  11. width: 20px;
  12. height: 20px;
  13. text-align: center;
  14. vertical-align: middle;
  15. }
  16. </style>
  17. <script type="text/javascript">
  18. var tbl = null;
  19. function hookTable(){
  20. tbl = document.getElementById("tblMain");
  21. if (tbl !== null){
  22. for(var i = 0; i < tbl.rows.length; i++){
  23. for (var j = 0; j < tbl.rows[i].cells.length; j++){
  24. tbl.rows[i].cells[j].onclick =
  25. function () { getVal(this);};
  26. }
  27. }
  28. }
  29. }
  30.  
  31. function getVal(cel){
  32.  
  33.  
  34. if (cel.innerHTML == 0) {
  35. cel.style.backgroundColor = "rgb(255,0,0)";
  36. }else{
  37. Math.round(Math.random()*255);
  38. }
  39. }
  40. </script>
  41. </head>
  42.  
  43. <body onload="hookTable();">
  44.  
  45. <?php
  46. $len = 10;
  47. echo '<table id="tblMain">';
  48. for($i = 0; $i < $len; $i++){
  49. echo "<tr>";
  50. for($j = 0; $j < $len; $j++){
  51. echo '<td>'.mt_rand(0, 1).'</td>';
  52. }
  53. echo "</tr>";
  54. }
  55. echo "</table>";
  56. ?>
  57.  
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement