The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Form inside a Form, how do you create a form inside a form?
kryles
post May 6 2009, 11:16 AM
Post #1


Novice
**

Group: Members
Posts: 21
Joined: 30-November 07
Member No.: 4,437



Hi,

I have a form which collects user input and proceeds to the next page. In this form I would like to add a different form that will direct the user to a seperate page if they click the button in form2. The placement of the form2 is rather important, otherwise I'd just put it after the closing of form1.

As is now, when the user clicks on button inside Form2 they are still directed to the page in Form1 action.

CODE

<Form1>
<input type=text> etc etc to collect info

<form2 target=_blank>
<input type=text>
<input type=submit>
</form>

<input type=image src="imageloc">

</form>


So using this pseudo code you can see how it is set up for now. Regardless which button is pressed the form actio is always taking the page in the first Form. Any way to do this so the Form in the Form (i.e. Form2) can be used?

Thanks,
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post May 6 2009, 11:37 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,731
Joined: 9-August 06
Member No.: 6



Because forms can't be nested. See http://htmlhelp.com/faq/html/forms.html#two-submit .
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 6 2009, 12:16 PM
Post #3


.
********

Group: WDG Moderators
Posts: 9,658
Joined: 10-August 06
Member No.: 7



To elaborate on the FAQ entry, you can let the server-side script (defined in the single form's ACTION attribute) redirect to different pages, depending on the submit button clicked. With PHP you can use isset() to find out which button was used.

A word of caution: using the BUTTON element for multiple submit buttons may cause bugs in MSIE browsers. Use INPUT submit buttons to be on the safe side.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 03:32 PM