File size: 3,339 Bytes
ce5f78d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5a8114c
ce5f78d
 
 
 
 
 
 
d9dd609
ce5f78d
 
 
 
c17c9f9
ce5f78d
5a8114c
ce5f78d
c30f331
 
 
 
 
c1f5fc1
 
 
ce5f78d
f400514
 
e86ce6d
 
 
f400514
07f4b00
ce5f78d
 
 
 
 
 
 
 
 
 
 
 
 
f400514
dab0266
ce5f78d
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!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 to generate a random number between min and max (inclusive)
        function getRandomNumber(min, max) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }

        // Function to fill the table with random numbers
        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;
                }
            }
        }

        // Generate the random table when the page loads
        window.onload = generateRandomTable;
    </script>
</body>
</html>