James Glass
James Glass

Reputation: 4300

Form Within A Form & Table Not Appearing

I have a form within a table which is within another form. My problem is that the embedded form tag is not appearing - the input and iframe appears, but the form tags do not appear. The table and outer form appear. What's wrong?

<form>
    <table id=\"mytableid\">
        <tr class=\"form_row\">
            <td align=\"right\">
                Upload&nbsp;Photo: 
            </td>
            <td align=\"left\">
                <form action=\"/myuploadpath\" method=\"post\" enctype=\"multipart/form-data\" target=\"upload_target\" id=\"photo_url_upload_form\" name=\"venue_photo_url_upload_form\">
                    <input type=\"file\" name=\"photo_url\" id=\"photo_url\"  size=\"40\" />
                    <iframe id=\"upload_target\" name=\"upload_target\" src=\"#\" style=\"width:0;height:0;border:0px solid #fff;\"></iframe>
                </form>
            </td>
        </tr>
    </table>
</form>

Upvotes: 0

Views: 1945

Answers (2)

m4tt1mus
m4tt1mus

Reputation: 1641

Putting a form inside another form is not valid HTML. When this happens each browser will do different things with the markup. Some ignore parts, some break, etc. Either way you shouldn't do this.

Edit

If you are using tables for layout purposes, you technically shouldn't be. They are only meant for tabular data. You should use divs/spans and CSS to create the look you want on your site. A great place to learn about this stuff is W3C Schools.

Upvotes: 5

nickf
nickf

Reputation: 546025

I assume you're using something like Firebug or the Chrome DOM Inspector to look at your DOM tree and you can't see the inner <form>. These tools inspect the DOM itself, not the HTML source. That is, they show you what the browser has interpreted from your HTML. The problem in this case is that nesting a <form> within another <form> is invalid, and hence the browser has ignored it and continued parsing the rest of the document.

Obviously, the fix is to ditch that outer form since it's not doing anything. If you have it there for styling purposes, perhaps use a <div> with a class.

Upvotes: 1

Related Questions