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

html file with multiple form elements

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a html file that contains a form with input fields.

within this form i have other forms, e.g. a form where the user can enter some text and through javascript the form is submitted and processed by a servlet which redirects back to the same page and the shows the entered data.
however, the problem is that i have input fields defined before the "sub-form". if i type in data in those fields and submit the "sub form" which goes to the servlet and the servlet redirects me back to the pack the data of the entered fields is lost. What would be the best solution to somehow keep the data of the "parent form"?

thanks in advance.
 
Sheriff
Posts: 67746
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

Originally posted by Viv Singh:
within this form i have other forms

Nested forms are not legal in HTML.
 
Viv Singh
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, what is the best solutions for the following problem?

i have a form that should be submitted e.g. to a servlet called serv1.

within that form i have a input field and next to it a hyperlink saying "add data". whenever the user types in something in that field and clicks on the hyperlink the servlet serv2 should be called as this needs the value of the text fields to store it in the database and in an object in the session.

thanks
 
Bear Bibeault
Sheriff
Posts: 67746
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
Sounds like a job for Ajax to me.
 
Viv Singh
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i solved it with javascript.
basically, what i do is, whenever the hyperlink is clicked i set the form action to serv2 and if submit is clicked i set the form action to serv1. that did the job..
 
Popeye has his spinach. I have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic