Collect all fields in form to an array

Posted by Industrial on Stack Overflow See other posts from Stack Overflow or by Industrial
Published on 2010-05-04T16:22:21Z Indexed on 2010/05/04 17:18 UTC
Read the original article Hit count: 190

Filed under:
|
|
|

Hi everyone,

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.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about php