Omzy Posted December 2, 2009 Share Posted December 2, 2009 Basically I have two forms on the page, both forms use GET method and have an ID attribute. I want the data from both forms to be included in the form submission whenever either of these forms are submitted. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 it does not make sense why you don't have one form instead ? Quote Link to comment Share on other sites More sharing options...
Omzy Posted December 2, 2009 Author Share Posted December 2, 2009 It's an estate agent site - one form is at the top and specifies the sort order and how many results per page, the other form is at the side and lets you refine the property features. Naturally you'd want to retain one form's options when the other form is submitted. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 your form tag can span the whole document it does not have to be at the specific location ?, so you can start the form tag at the first form and end it at the second form ends Quote Link to comment Share on other sites More sharing options...
Omzy Posted December 2, 2009 Author Share Posted December 2, 2009 Well there are more forms within the body of the document. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 the you got one option make a third hidden form with both values from both the forms, on sumbit of any one of the forms through javascript populate the third form and submit that form. Quote Link to comment Share on other sites More sharing options...
Omzy Posted December 2, 2009 Author Share Posted December 2, 2009 give me example code please. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 you can try this did not check it though <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <script type="text/javascript"> function consolidate() { form1 = document.getElementById('form1'); form2 = document.getElementById('form2'); form3 = document.getElementById('form3'); form3.test.value = form1.test.value; form3.test1.value = form2.test1.value; form3.submit(); } </script> </HEAD> <BODY> <form id="form1" onsubmit="consolidate(); return false;"> <input type="text" name="test" value="2" /> <input type="submit" value="submit1" /> </form> <form id="form2" onsubmit="consolidate(); return false;"> <input type="text" name="test1" value="2" /> <input type="submit" value="submit1" /> </form> <form id="form3" > <input type="hidden" name="test" value="" /> <input type="hidden" name="test" value="" /> </form> </BODY> </HTML> Quote Link to comment Share on other sites More sharing options...
Omzy Posted December 2, 2009 Author Share Posted December 2, 2009 Thanks, that's perfect. Quote Link to comment Share on other sites More sharing options...
Omzy Posted December 4, 2009 Author Share Posted December 4, 2009 Actually this won't work when JavaScript is disabled, so is there any other method? Quote Link to comment Share on other sites More sharing options...
premiso Posted December 4, 2009 Share Posted December 4, 2009 Combine the forms into one? Other than that, I do not think there is. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted December 4, 2009 Share Posted December 4, 2009 Yeah, this definitely sounds like a design issue. OP, mind giving us a more clear example (or, better yet, your code thus far) illustrating what you're trying to do? Quote Link to comment Share on other sites More sharing options...
Zane Posted December 4, 2009 Share Posted December 4, 2009 Unless you use Javascript (your best bet) you'll have to use ONE FORM and make it span the entire body of your document...just to be safe. </pre> <form> //Form One //Form Two </form> <b This way you can put as many submit buttons as you possibly need.. Then on your receiving page.. just check for which submit button they clicked.. since the other submit buttons will not be sent through... Though any fields that were filled in will still be sent. It will give the illusion you are using multiple forms. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted December 5, 2009 Share Posted December 5, 2009 It sounds to me like the OP is building his action attribute of the form in such a manner that it "forgets" the query string that generated the page request. Fix that and it should be fine. Quote Link to comment Share on other sites More sharing options...
Omzy Posted December 5, 2009 Author Share Posted December 5, 2009 roopurt18 - no that's not true. besides you can't include query parameter's in the form's ACTION attribute. I think I'm just gonna combine both forms in to one, as has been suggested. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted December 6, 2009 Share Posted December 6, 2009 besides you can't include query parameter's in the form's ACTION attribute. Since when? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.