File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes multiple forms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "multiple forms" Watch "multiple forms" New topic

multiple forms

deepika malhotra

Joined: Nov 21, 2005
Posts: 11
I have a html file in which I would like to have two forms. In the first form I will have a check box which if checked then the second form should take values entered by the user in the first form and submit to a location. This should not happen if the checkbox is not checked by the user. I request for an idea on how this is done in HTML.

Thanks in advance

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Why do you think you need more than one form?

[Asking smart questions] [About Bear] [Books by Bear]
deepika malhotra

Joined: Nov 21, 2005
Posts: 11
OK, here is what I need to do. I am not sure if I need two forms.

I need to collect name address phone number etc form the user. I need this to be sent by email.

Second thing is if they choose to be joined in a mailing list by checking a check box their information should be sent to another location with some of the user entered details. This doesn't happen if user doesn't check the checkbox. In either case sending of all the user entered values by email should take place.

I was thinking there would one form in which the action is to direct the information to a cgi program which will email the information. There will be a second form which chould check the user's consent and then collect some of the details like name and email and send this to an external location where these details are maintained.

Do you mean I can submit selective details to one location and some other details to another location without using two forms? Can you explain how?


Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
You are only going to be able to submit one form at a time so one submission would take two clicks.

You really need a server side page that performs both actions.

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367

You can use the same form. Let's say you have 10 fields in the form . Some information to send as email and other fields to another page.

If the user checks a box or presses a button you can change the forms action by doing the following.

document.forms[ "myform" ].action = "my new page"

you can post the data into a hidden frame and then call a javascript from the frame when the information is sent

parent.frames[ "myFrame" ].myfunction();

If there are 2 forms please follow Erics post.
[ December 12, 2005: Message edited by: Mathias Nilsson ]

I agree. Here's the link:
subject: multiple forms
It's not a secret anymore!