wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes html file with multiple form elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "html file with multiple form elements" Watch "html file with multiple form elements" New topic
Author

html file with multiple form elements

Viv Singh
Ranch Hand

Joined: Nov 08, 2008
Posts: 73
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60761
    
  65

Originally posted by Viv Singh:
within this form i have other forms
Nested forms are not legal in HTML.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Viv Singh
Ranch Hand

Joined: Nov 08, 2008
Posts: 73
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60761
    
  65

Sounds like a job for Ajax to me.
Viv Singh
Ranch Hand

Joined: Nov 08, 2008
Posts: 73
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..
 
 
subject: html file with multiple form elements
 
Similar Threads
How to remember HTML Form fields with Servlets
Reatining Form Values After an exception is thrown
form validation
retaining values in a posted form...
Browser Back button handling wusing spring