tags:

views:

66

answers:

3

I have to submit two forms; one is on the page, while the other is coming through combo change event using jquery. I have to get both of these forms values on the same page. Please help me I have already wasted much time.

My code looks like this:

this function which i'm calling on the button click to submit both forms

function forms_submit()
{

document.form1.submit(); 
document.form2.submit();

}
+1  A: 

You cannot submit two forms.. since your are in a browser, you can only end to one page.. and it depends on which form you submit.. (unless you go the ajax way)

perhaps you want to merge the forms in a single form in your HTML..

Give some more info/code to get some more specific answers..

Gaby
no i want ,two separate forms to be submitted on single click can u help?
@user403269 you cannot without Ajax submission .. look at this plugin for more info on a jQuery implementation .. http://jquery.malsup.com/form/
Gaby
A: 

If your submit your reason, probably I could submit your 2 forms

-----------edited--------------

var whatever ='<span id='updated_values'><input type=hidden></span>';
use $('#div').append(whatever);

Each time you select a category trigger the whatever to append the an existing form as hidden form type, you need to catch the variables at time of form submission.

Hope this solves your issue.

Jean
i have one form which contain categories for the product when a category is selected below a form using jquery appear with input fields each category has different form now both form fill by the user and then submit , i need both forms value on the same page so that i can insert them in to db , got it?
You don't NEED two forms for this. Why didn't you combine the two forms into one?
Rosdi
check out my edited answer
Jean
well that was really good idea , it worked in fact very very thanks
pls accept the answer.....
Jean
A: 

You can use XMLHTTPRequest to send both forms, (but that requires two requests you'd be wasting instead of one) I would recommend joining the forms together.

anyways a codesample,

btnSubmitBoth.onclick = function () {
    var xmlReq,
    data = getFormsData(); // needed to be in format of "something=1&sometinelse=2"
    if (typeof XMLHttpRequest !== 'undefined' && (window.location.protocol !== 'file:' || !window.ActiveXObject)) {
         xmlReq = new XMLHttpRequest();   
     } else {
          try {
                 xmlReq = new ActiveXObject('Msxml2.XMLHTTP.6.0');     
         } catch(e) { }     
         try {
             xmlReq = new ActiveXObject('Msxml2.XMLHTTP.3.0');     
         } catch(e) { }     
         try {
                xmlReq = new ActiveXObject('Msxml2.XMLHTTP');     
        } catch(e) { }   
    }
xmlReq.open("post", url, true);
xmlReq.send(data);
}
Shlomi