File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Many form tags in html Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Many form tags in html" Watch "Many form tags in html" New topic
Author

Many form tags in html

michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
Is it possible to put a few different form tags in a html page and the page still works properly? I wanted to create a page with a few input fields and a few submit buttons . Each different submit button clicked will pass different parameters to another page. Example there are name, age and gender fields with 3 submit buttons assigned to each of them. When i click submit button for name, only the parameter of name will be passed. Or are there a different way to accomplish this.
Thanks.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31054
    
162

Rollin,
You can't use different form tags unless the form fields are distinct. You can have each button call a javascript function which sets a different form action and then submits the page:


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Yeah you can have multiple form tags, they just can't be nested within each other.
Also, only the fields defined within each form block will be submitted the "action" URL specified.
michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
Thanks for the quick reply guys.
Now I have a drop down box named groupings and I want this particular parameter value to be passed for whatever submit button clicked. Example I click the submit button for name and it also pass the groupings parameter. I click the age submit button and groupings parameter is passed and so on.
Can I achieve this in html or do I have to put the drop down groupings box for each and every form tags in my html so that it got passed. If I do this I am afraid there is redundancy.
Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
you can use javascript to take that one filed and apply it to hidden elements located in the other form fields...
michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
Dear Eric,
May I know how to do your suggestion using javascript. I tried using jsp but it seems unable to pass value.
I put this in other form tags
<input name="groupselc" type="hidden" value=<%= nameg%>>
with nameg being the name of the drop down box.
I did not put the drop down box in form tag though. Do I need to put it in a form tag with another name. Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Many form tags in html