• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Many form tags in html

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic