This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
Author

How can I get a form name

Gerry Mueller
Greenhorn

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

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
Marshal

Joined: Jan 10, 2002
Posts: 60745
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
parampreet sethi
Greenhorn

Joined: Aug 03, 2009
Posts: 27

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



regards
param


Param
Gerry Mueller
Greenhorn

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.

by
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I get a form name
 
Similar Threads
Adding an image to form header
to set the number in currency
Adding an image to form header
Using form based authentication and Struts
jdbc-servlet