Closed Bug 402321 Opened 17 years ago Closed 17 years ago

A form generated in innerhtml will submit to wrong place.

Categories

(Firefox :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 22480

People

(Reporter: hartian, Unassigned)

Details

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9a9pre) Gecko/2007110212 Minefield/3.0a9pre Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9a9pre) Gecko/2007110212 Minefield/3.0a9pre If a <form> is generated dynamically in innerhtml it will submit to an existing <form>. Much easier to show with a sample :) <html> <script> function generate_form() { doc=document.getElementById('someajax'); doc.innerHTML='<form action="/bar"><input type=submit value="should submit to /bar"></form>'; } </script> <body> <a href="#" onclick="generate_form()">Generate a form</a> <form id="1" action="/foo"><p> <input type=submit value='should submit to /foo'> </form> <div id="someajax"> </div> </body> </html> Reproducible: Always Steps to Reproduce: 1. load up the html code in details 2. click the link 'generate a form' 3. click the submit button 'should submit to bar' 4. Notice where the submit goes too, it will go to the foo action. Expected Results: On submit it should go to /bar
The problem is that the <p> makes the </form> get ignored, so that the <div> is inside the existing form. And then you're trying to put the new <form> inside the existing <form>, which is not allowed, so the new <form> tag is ignored.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.