-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
64 lines (61 loc) · 1.57 KB
/
test.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
54
55
56
57
58
59
60
61
62
63
64
<script src="jquery.js"></script>
<script type="text/javascript">
// 2006-08-21 - Created
// 2006-11-05 - Modified - head and body
function addColumn(tblId)
{
var tblHeadObj = document.getElementById(tblId).tHead;
for (var h=0; h<tblHeadObj.rows.length; h++) {
var newTH = document.createElement('th');
tblHeadObj.rows[h].appendChild(newTH);
newTH.innerHTML = 'KW2' + h + ', cell: ' + (tblHeadObj.rows[h].cells.length - 1)
}
var tblBodyObj = document.getElementById(tblId).tBodies[0];
for (var i=0; i<tblBodyObj.rows.length; i++) {
var newCell = tblBodyObj.rows[i].insertCell(-1);
newCell.innerHTML = '[td] row:' + i + ', cell: ' + (tblBodyObj.rows[i].cells.length - 1)
}
}
function deleteColumn(tblId)
{
var allRows = document.getElementById(tblId).rows;
for (var i=0; i<allRows.length; i++) {
if (allRows[i].cells.length > 1) {
allRows[i].deleteCell(-1);
}
}
}
</script>
<form>
<select onchange="addColumn('tblSample')">
<option value="1">1pcs</option>
<option value="2">2pcs</option>
<option value="3">3pcs</option>
</select>
</form>
<table border="1" id="tblSample">
<thead>
<tr>
<td>Error</td>
<td>KW2</td>
<td>KW3</td>
</tr>
</thead>
<tbody>
<tr>
<td>Error 1</td>
<td><input type="text" name="error[]"></td>
<td><input type="text" name="error[]"></td>
</tr>
<tr>
<td>Error 2</td>
<td><input type="text" name="error[]"></td>
<td><input type="text" name="error[]"></td>
</tr>
<tr>
<td>Error 2</td>
<td><input type="text" name="error[]"></td>
<td><input type="text" name="error[]"></td>
</tr>
</tbody>
</table>