I am new in php.I made and html Dynamic Table on which there are 2 following fields that are dynamically generated for each time the user presses Add/Remove Button:
Image Sample given below:
Here the html Code given below:
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border-collapse: collapse;
}
</style>
<script>
function addMore() {
var table = document.getElementById("myTable");
var row = table.insertRow(-1);
var cell1 = row.insertCell(-1);
var cell2 = row.insertCell(-1);
var x = document.getElementById("myTable").rows[1].cells;
cell1.innerHTML = x[0].innerHTML;
cell2.innerHTML = x[1].innerHTML;
}
function removeLast() {
document.getElementById("myTable").deleteRow(-1);
}
</script>
</head>
<body>
<form action="data.php" method="post">
<table id="myTable">
<tr>
<th>Options</th>
<th>User Input</th>
</tr>
<tr>
<td>
<select class="mySelect" name="DESCR" >
<option disabled="" selected="">Select</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select>
</td>
<td> <input type="text" name="ALAMT"></td>
</tr>
</table>
</form>
<br>
<button onclick="addMore()">Add New</button>
<button onclick="removeLast()">Remove</button>
<button onclick="myFunction()">Try it</button>
</body>
</html>
After choosing option and inputing vaules to this table,i want to submit their data to php using $_POST[ ]
Because they are Dynamic,it will be time consuming & inefficient to maintain unique name or Id for each of
them.So,What code should i write in php to do so.please let me know for any further information.Thanks
