Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I get a form name

 
Gerry Mueller
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am there again!

I have more than 1 form in a jsp page. How can I know which forms was clicked at once?

Please help!!!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean in an onclick handler? This seems more of an HTML question; moving.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are relying on the name of the form, I'd say your design has failed.

If you need metadata to be submitted along with user input, that's what hidden form fields are for.
 
parampreet sethi
Greenhorn
Posts: 27
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one way is to pass the object reference in your javascript method call on form submission.



regards
param
 
Gerry Mueller
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I solve the problem adding a hidden field (with the same name <forms>) in each forms. Each of those field has a different value (for example form1, form2, form3, ...).
So i can now check which form was clicked getting parameter with request.getParameter("forms");.

That is the easier way to solve the problem i think.

by
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic