-
Notifications
You must be signed in to change notification settings - Fork 0
/
tableextract.html
53 lines (47 loc) · 1.06 KB
/
tableextract.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<table id="myTable">
<tr>
<th>Name</th>
<th>Age</th>
<th>Gender</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
<td>Male</td>
</tr>
<tr>
<td>Jane</td>
<td>30</td>
<td>Female</td>
</tr>
<tr>
<td>Bob</td>
<td>40</td>
<td>Male</td>
</tr>
</table>
<label for="rowIndex">Enter Row Index:</label>
<input type="number" id="rowIndex">
<button onclick="fetchData()">Fetch Data</button>
<p id="output"></p>
<script>
function fetchData() {
const rowIndex = document.getElementById("rowIndex").value;
const table = document.getElementById("myTable");
const name = table.rows[rowIndex].cells[0].innerHTML;
const age = table.rows[rowIndex].cells[1].innerHTML;
const gender = table.rows[rowIndex].cells[2].innerHTML;
const output = document.getElementById("output");
output.innerHTML = `Name: ${name}, Age: ${age}, Gender: ${gender}`;
}
</script>
</body>
</html>