Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple form submit in jsp

 
Mayank Adhikari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a jsp file in which there are two different forms "f1" & "f2". I am having below three conditions

1. I have to submit form f1 only
2. I have to submit form f2 only
3. I have to submit form f1 & f2 both

for 3rd condition mentioned above, i need a single button by which i can submit both the form f1 & f2.
currently i am using the below java script but its now working ane giving me null value when i am trying for both form submission.

Please find below my jsp code:
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why don't you combine both fields in a single form? What is the business need?

If you can't do that, before submitting your form set value of a field in hidden field of other form.
 
Mayank Adhikari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In the above code i just show two fields where in actual i have 40+ fields (including some drop downs) so using hidden value will be a bit problematic.

i need to have separate form submission option because i have three scenarios as mentioned in the initial post.
so can you please sugget me on a alternative.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64847
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot submit two forms at the same time.

You haven't really explained why you feel that you need to.
 
Mayank Adhikari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply..

On my page i am giving the flexibility to user that they might only enter the data for one form and keep the other for blank. then i need to update the single form only.
If user enter data in both forms then i have to update the full data.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64847
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still not seeing why there needs to be two forms.
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try solving this problem using ajax.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64847
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to hear more about what's actually trying to be accomplished before jumping to Ajax.
 
Bill Clar
Ranch Hand
Posts: 163
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not use one form with two different submit buttons? Use only the form data you need based on the submit button the user presses.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic