【问题标题】:add/remove multiple input fields and input rows dynamically PHP (Dynamic form In Dynamic Form)动态添加/删除多个输入字段和输入行 PHP(动态表单中的动态表单)
【发布时间】:2021-07-28 09:52:45
【问题描述】:

我正在制作动态 PHP 表单,我已经成功制作了动态表单,如果我想在动态字段中使表单动态化,例如在表格中在动态行中制作动态字段,该怎么办?

this is my form view

$(document).ready(function(){
      var count = 0;
      $(document).on('click', '#addformdanger', function(){
        count++;
        var html = '';

                  html += '<section>';
                  html += '<hr>';
                  html += 'my child form';

$('#form-body-danger').append(html); 
});
$(document).on('click', '#addprocess', function(){
        count++;
        var html = '';

                  html += '<section>';
                  html += '<hr>';
                  html += 'form child';

$('#form-body-process').append(html);
});


$(document).on('click', '.remove-danger',function(){
               $(this).closest('section').remove();
            });

$(document).on('click', '.remove-process',function(){
               $(this).closest('section').remove();
            });

this My Output what i want,

【问题讨论】:

  • 通过向我们展示输出或代码的任何图像或详细说明场景来使这一点更加清晰。
  • 我已经更新了我的问题,你能帮我吗,谢谢
  • 通过您想要的输出图像,您的问题与HTML有关。也许您想在 html 表格中执行 rowspancellspan ,或者您想要使用 CSS 执行此操作,但在这两种情况下,您的问题都过于抽象;如果您可以提供reproducible example,您更有可能获得有用的答案。无论如何,您应该首先尝试编写您想要显示的最终 html 代码,然后从那里,您会发现很容易提取需要由 jQuery(或 PHP)附加的 html 部分

标签: php jquery forms dynamic-forms dynamicform


【解决方案1】:

根据您所提到的,我的理解是您正在制作一个用户可以添加多个输入的表单。点击提交后,数据应发送回服务器。

如果这是问题,请visit here

你也可以refer

两者都将帮助您创建用户可以根据需要添加/删除更多字段的表单。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-06
    • 2011-07-20
    • 1970-01-01
    • 1970-01-01
    • 2016-07-30
    • 2021-06-23
    • 1970-01-01
    相关资源
    最近更新 更多