jQuery in Action, 3rd edition
The moose likes HTML, CSS and JavaScript and the fly likes How can I get a form name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How can I get a form name" Watch "How can I get a form name" New topic

How can I get a form name

Gerry Mueller

Joined: Dec 30, 2009
Posts: 17

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

Joined: Sep 29, 2008
Posts: 12617

Do you mean in an onclick handler? This seems more of an HTML question; moving.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

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.

[Asking smart questions] [About Bear] [Books by Bear]
parampreet sethi

Joined: Aug 03, 2009
Posts: 27

one way is to pass the object reference in your javascript method call on form submission.


Gerry Mueller

Joined: Dec 30, 2009
Posts: 17
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.

I agree. Here's the link: http://aspose.com/file-tools
subject: How can I get a form name
It's not a secret anymore!