ajax submit multiple forms via jquery -
so suppose have 3 forms
<form name="form1"> <input name="input"></input> <submit></submit> </form> <form name="form2"> <input name="input"></input> <submit></submit> </form> <form name="form3"> <input name="input"></input> <submit></submit> </form> each of form has own submit button
now suppose have form
<form id="submitall"> <submit value="submit all"></submit> </form> whose sole function submit other 3 forms simultaneously....now here constraints:
- when submitall submitted, has using ajax , forward input data other 3 forms processor.php preferably via post
- processor.php needs able distinguish between inputs go form...and process inputs of each form separately
my question is....what best way make processor.php able distinguish inputs belong form.....
my previous attempts use jquery's serialize serialize 3 forms' inputs, merge inputs 1 string , notice since inputs in forms have same name, string goes "input=blah&input=blah&input=blah" , can't distinguish between input goes form.....
it highly preferable have inputs in forms have same name processor.php can execute smoothly
is there away make post strings passed arrays or json or other format processor.php can distinguish input goes form without making input names differ? remember needs via ajax
thanks in advance!!!
why don't use naming convention like
- name="form1[input]"
- name="form2[input]"
- name="form3[input]"
then regular serialize , $.post, keep same naming convention in processor loop
edit:
<?php foreach($_post $form) { // $form = array('input' => 'i here') processform($form); // names still same forms } ?>
Comments
Post a Comment