I have a JavaScript function which multiplies a DOM element.
I hit it 2 times (for example) and I get 3 Elements like this:
<!-- How to show all my new Elements after refresh? -->
<tr id="toBeMultiplied">
<td>
<!-- How to echo the value of this input? -->
<input type="text" name="numbers[]" />
</td>
<td>
<!-- How to echo the value of this input? -->
<input type="text" name="titles[]" />
</td>
<td>
<!-- How to echo the value of this input? -->
<input type="text" name="lengths[]" />
</td>
</tr>
But this is just a small part of a big Form! When I click on Submit, those new Elements I’ve just created disappear.
So, I want to make my new Elements to not disappear.
You could count how many values are in, say, numbers array on POST.
For example:
$i = count($_POST['numbers'])And then create a loop that will print the form as many times as it existed before.
If you end up using
$ias a count of elements, you could then fill in the previous values back into the form as such:$_POST['numbers'][$i]