Each div with the class “row” is added upon request from the user, to be able to add multiple items at once. So now is the question how I’ll collect all the forms in to an array that PHP can read (like JSON for instance). I’ll guess that there’s already some easy and effective way of doing this?
<div class="container">
<div class="row">
<input type="text" name="value1" id="textfield" />
<input type="text" name="value2" id="textfield" />
<input type="text" name="value3" id="textfield" />
</div>
</div>
Here’s what I would like to achieve out of the shown example:
array(
array ('value1' => '',
'value2' => '',
'value3' => '')
);
Thanks!
Update:
The form will be handled with PHP and it would be super to be able to do something like a foreach loop on the specific container-div content.
Give each ‘group’ of inputs the same name, then add square brackets to the end
When you post the form, your php
$_POSTvariable will then contain arrays forvalue1,value2andvalue2:You can then iterate through to ‘regroup’ the rows within PHP (but first, i’d change the field names to field1 etc rather than value1):
This would give: