Kerberos
Kerberos

Reputation: 4166

Save dynamically created form elements into xml

I'm working to a webserver for a mobile application. I want to create a php page where the user decide by letting them add new form elements with a click of a mouse and then the values of these forms saved into an xml file. I use a function like this for add the forms:

 $('a#add').click(function() {
            $('<p><input type="text" name="items[]" id="' + i + '" value="' + i + '" /><select name="items[]"><option value="1">Light</option><option value="2">Shadow</option></select><a href="#" class="remove"> Remove</a></p>'); 
            i++;        
            return false;
    });

Now how can I save all the values of all the forms into an array? Then I must copy all the values into an xml file with simplexml. Excuse me but I'm a newbie of this language.

Thanks.

EDIT

With this code it pass an array and then on the php page we can store the value of the array into a variable as "$bits = $_POST['items'][0];"

Upvotes: 0

Views: 232

Answers (1)

Johannes Mittendorfer
Johannes Mittendorfer

Reputation: 1252

Wrap your code with an <form action="foo.php"> tag. The action value describes to which php-page the form-values get sent after submit.

Within the php-page the values are available in $_GET.

(Also works with method="POST" and $_POST.)

Upvotes: 2

Related Questions