• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Many form tags in html

 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
James Swan
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic