• 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
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

dynamic form processing

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to be able to process form data dynamically based on what selection a user makes but am unsure of whih approach to take.
Basically, I want to have a form with 2 or 3 submit options. On submit, the form data is forwarded to the appropriate servlet depending on which submit button was clicked.
How would I do this - can I add some variable to the <form action="/servlet/???"> tag or is it possible to have the individual button forward the form data to a location based on the button's value?
Thanks in advance
Dave
 
Sheriff
Posts: 67734
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dave, either approach is viable.
If the server-side form processing is similar for the various situations, I think it'd be best to set a hidden parameter on the form that the servlet (or whatever's doing the form processing) can use to adjust the processing accordingly.
If the processing will be different for each case, you can modify the action attribute of the form to specify completely different servlets.
Which approach you take depends upon what makes the most sense for your app.
In either case, this is purely an HTML/Javascript operation, so we might want to move this dicussion here.
hth,
bear
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the button's value seems to be a cleaner option
 
Screaming fools! It's nothing more than a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic