-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
55 lines (51 loc) · 1.19 KB
/
test.php
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
<!DOCTYPE html>
<html>
<head>
<style>
table, td {
border: 1px solid black;
}
</style>
</head>
<body>
<p>Click the button to add a new row at the first position of the table and then add cells and content.</p>
<form method="post" action="http://www.moraetamils.com">
<table id="myTable">
<tr>
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td><input type='text'></input></td>
<td><input type='text'></input></td>
</tr>
<tr>
<td><input type='text'></input></td>
<td><input type='text'></input></td>
</tr>
</table>
<br>
<button onclick="myFunction()">Add</button>
<button onclick="delefun()">Delete</button>
<button type="submit">Submit</button>
</form>
<script>
var counter = 2;
function myFunction() {
counter++;
var table = document.getElementById("myTable");
var row = table.insertRow(-1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = '<input type="text" value="counter" requried></input>';
cell2.innerHTML = "<input type='text' requried></input>";
}
function delefun(){
var table = document.getElementById("myTable");
if(table.rows.length>2){
table.deleteRow(-1);
}
}
</script>
</body>
</html>