douao1858 2019-05-18 14:39
浏览 39
已采纳

如何自动获取多个表单

I'm doing a HTML form, it's meant to create step to pass on a game and I want to be able to enter a number and when for example I enter 5 it instantly show me 5 form to fill and create new step but when I try it doesn't appear how can I do please?

<h3>Insertion des étape :</h3>

<form action="InsertionEtape.php" method="post">
    <input type="number" name="quantity" min="1" max="5">
    <br>
    <?php for ($i=0; $i < $_GET['quantity']; $i++) {
       ?>
        <h5>Nom de l'étape</h5>
        <input type="text" name="NomEtape" size="40" maxlength="40">
        <br>

        <h5> Description de l'étape </h5>
        <textarea name="DescriptionEtape" rows="8" cols="80"></textarea>
        <br>
        <br>
        <input type="submit" value="Valider">
        <?php
     } ?>
</form>
  • 写回答

3条回答 默认 最新

  • doukuiqian5345 2019-05-18 15:16
    关注
    <h3>Insertion des étape :</h3>
    <form action="index.php" method="post">
        <input type="number" name="quantity" id="quantity" min="1" max="5"> 
        <div id="formcontainer">
        </div>
        <input type="submit" value="Valider">
    </form>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
        jQuery(function($) {
            $("#quantity").bind('keyup mouseup', function () {
                var count = $('#quantity').val();
                var htmlf = '';
                for (i = 0; i < count; i++) {
                    htmlf += "<h5>Nom de l'étape</h5><br/>";
                    htmlf += '<input type="text" name="NomEtape_"'+i+' size="40" maxlength="40">';
                    htmlf += "<h5>Description de l'étape</h5><br/>";
                    htmlf += '<textarea name="DescriptionEtape_"'+i+' rows="8" cols="80"></textarea>';
                    htmlf += "<br/>"
                }
                $("#formcontainer").html(htmlf);
            });
        });
    </script>
    

    Simple Just run the code and you can find yourself easy.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题