| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Random 3x3 Table</title> |
| <style> |
| body { |
| font-family: Arial, sans-serif; |
| display: flex; |
| flex-direction: column; |
| align-items: center; |
| justify-content: center; |
| height: 100vh; |
| margin: 0; |
| background-color: #f5f5f5; |
| } |
| h1 { |
| color: #333; |
| margin-bottom: 20px; |
| } |
| table { |
| border-collapse: collapse; |
| margin-bottom: 20px; |
| box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); |
| } |
| th, td { |
| border: 1px solid #ddd; |
| padding: 15px; |
| text-align: center; |
| background-color: white; |
| } |
| th { |
| background-color: #4CAF50; |
| color: white; |
| } |
| button { |
| padding: 10px 20px; |
| background-color: #4CAF50; |
| color: white; |
| border: none; |
| border-radius: 4px; |
| cursor: pointer; |
| font-size: 16px; |
| transition: background-color 0.3s; |
| } |
| button:hover { |
| background-color: #45a049; |
| } |
| </style> |
| </head> |
| <body> |
| <h1>Random 3x3 Table</h1> |
| <table id="randomTable"> |
| <thead> |
| <tr> |
| <th>Row ID</th> |
| <th>Column 1</th> |
| <th>Column 2</th> |
| <th>Column 3</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><strong>Row B</strong></td> |
| <td id="cell-0-0"></td> |
| <td id="cell-0-1"></td> |
| <td id="cell-0-2"></td> |
| </tr> |
| |
| <tr> |
| <td><strong>Row C</strong></td> |
| <td id="cell-2-0"></td> |
| <td id="cell-2-1"></td> |
| <td id="cell-2-2"></td> |
| </tr> |
| <tr> |
| <td><strong>Row D</strong></td> |
| <td id="cell-3-0"></td> |
| <td id="cell-3-1"></td> |
| <td id="cell-3-2"></td> |
| </tr> |
| <tr> |
| <td><strong>Row E</strong></td> |
| <td id="cell-1-0"></td> |
| <td id="cell-1-1"></td> |
| <td id="cell-1-2"></td> |
| </tr> |
|
|
| </tbody> |
| </table> |
| |
| <button onclick="generateRandomTable()">Generate New Random Table</button> |
|
|
| <script> |
| |
| function getRandomNumber(min, max) { |
| return Math.floor(Math.random() * (max - min + 1)) + min; |
| } |
| |
| |
| function generateRandomTable() { |
| for (let i = 0; i < 5; i++) { |
| for (let j = 0; j < 3; j++) { |
| const cellId = `cell-${i}-${j}`; |
| const randomValue = getRandomNumber(1, 100); |
| document.getElementById(cellId).textContent = randomValue; |
| } |
| } |
| } |
| |
| |
| window.onload = generateRandomTable; |
| </script> |
| </body> |
| </html> |