I have created a php form which appends new text variables like this:
<form action="" enctype=”multipart/form-data” method="post" action="<?php echo $_SERVER['REQUEST_URI'];?>">
<div id="div">
value <input type="text" name="tst" >
<button onclick ="appendRow()" value="Add Row">Add Row</button>
<input type="submit" value="test" name="submit" >
</div>
</form>
I have added the following java script to it:
<script>
var x=1
function appendRow()
{
var d = document.getElementById('div');
d.innerHTML += "<input type='text' name='tst"+ x++ +"'><br >";
}
</script>
Now I want to store all the variables I get from the form and use them for further calculations. I tried the for each loop for that:
if (isset($_POST['submit']) && is_array($_POST['submit'] == "test")) {
foreach($_POST["submit"] as $key => $tst){
$capture_field_vals .= $tst .", ";
}
echo $capture_field_vals;
But nothing is happening. Can you please tell me what is wrong ?