• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to submit two forms on same page?

 
Abhishek Anne
Greenhorn
Posts: 4
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
0 down vote favorite
share [fb] share [tw]


Case:

I have two forms
1> Own Customized Form say form1.
2> Form rendering from third party java script call say form2.

Previously there was only one form
(no third party form) with same fields.
Thus I was submitting it using single submit button.
Lets say I was calling Action1 for my old form.

The third party form has own submit button and it post values (Not all. Only Third Party
values ) to own controller and returns response .

I don't want to ask user to submit twice on same page.

I want to submit both forms on old submit button and hide third party submit button.

I can change the response URL (where to land to get third party form submit response ).

I am thinking to hide third party submit button with css and call click/submit that when I
click old submit button using javascript.

Lets set response landing page for third party to Action1.

But if I land on old action ie Action1 I cant able to get old customized form element?

I am stuck in this scenario.

Can you have any better solution to this?

[Using struts framework and jsp for rendering form.]
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may not submit two forms, but you can chose to submit how many fields you want to submit. After all that is what you would be wanting to do - submit data.
 
john lazeraski
Ranch Hand
Posts: 76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way you can do it is using JavaScript and ajax, you can grab all the values of the two forms and build up a single ajax request. ajax requests would work similar to a form submit.. should be easy enough to handle it for one request with one action class. You may need to figure out the 3rd party component fields and modify them in your JS so as to properly auto-populate your own custom bean that the action class can then use.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic