Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet Explorer Nested Form Post

I'm am using ASP.NET MVC to create a page that posts to the Paypal sandbox. My form that posts to the Paypal site is nested inside a parent form. I am using Internet Explorer 7, and for some reason, the nested form posts to my local machine instead of the paypal site. If I add a copy of the same nested form directly after the first, the first one posts to localhost, and the second posts to where it is expected.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>
    </title>
</head>
<body>
    <form name="aspnetForm" method="post" action="" id="aspnetForm">        
        <!--First form posts locally-->
        <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
            <input type="submit" value="Pay"/>
        </form>     

        <!--Second identical form posts to the expected destination-->
        <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">     
            <input type="submit" value="Pay"/>
        </form> 
    </form>

like image 249
bingles Avatar asked Jun 23 '10 13:06

bingles


People also ask

Can you nest a form within a form?

Every form must be enclosed within a FORM element. There can be several forms in a single document, but the FORM element can't be nested.

Can we have a form within a form?

You are not allowed to nest form elements. If the forms were separate (not nested) you can submit a different form using the form attribute on an input.

Can we have nested forms?

Using nested forms, we can create an array of objects within a single field and we can have an array of these fields. Hence, the nested form helps us manage large form groups and divides it into small groups. For example: A company decides to issue a form to collect data from users.

Can we use form tag inside form tag?

No, nested forms are forbidden. This means A FORM has a mandatory start tag, mandatory end tag and can contain anything in %block or SCRIPT, except other FORMs.


2 Answers

Nested forms are not vaild, and therefore their behavior is undefined. You just cannot nest them. Only one form can submit at a time, though you can have multiple, unnested forms on a page (only the one of the corresponding submit button will be submitted, though).

like image 170
Palantir Avatar answered Oct 07 '22 18:10

Palantir


Looks like I used the ASP.NET master page template instead of the ASP.NET MVC one. The ASP.NET template includes a form tag which is what created this nested form page. Using the ASP.NET MVC template fixed my problem by removing the nested forms altogether.

like image 40
bingles Avatar answered Oct 07 '22 18:10

bingles