Is it valid to have a html form inside another html form?

前端 未结 14 1790
故里飘歌
故里飘歌 2020-11-22 06:01

Is it valid html to have the following:

相关标签:
14条回答
  • 2020-11-22 07:02

    In case someone find this post here is a great solution without the need of JS. Use two submit buttons with different name attributes check in your server language which submit button was pressed cause only one of them will be sent to the server.

    <form method="post" action="ServerFileToExecute.php">
        <input type="submit" name="save" value="Click here to save" />
        <input type="submit" name="delete" value="Click here to delete" />
    </form>
    

    The server side could look something like this if you use php:

    <?php
        if(isset($_POST['save']))
            echo "Stored!";
        else if(isset($_POST['delete']))
            echo "Deleted!";
        else
            echo "Action is missing!";
    ?>
    
    0 讨论(0)
  • 2020-11-22 07:02

    A non-JavaScript workaround for nesting form tags:

    Because you allow for

    all fields minus those within "b".

    when submitting "a", the following would work, using regular web-forms without fancy JavaScript tricks:

    Step 1. Put each form on its own web page.

    Step 2. Insert an iframe wherever you want this sub-form to appear.

    Step 3. Profit.

    I tried to use a code-playground website to show a demo, but many of them prohibit embedding their websites in iframes, even within their own domain.

    0 讨论(0)
提交回复
热议问题