【发布时间】:2021-07-28 09:52:45
【问题描述】:
我正在制作动态 PHP 表单,我已经成功制作了动态表单,如果我想在动态字段中使表单动态化,例如在表格中在动态行中制作动态字段,该怎么办?
$(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();
});
【问题讨论】:
-
通过向我们展示输出或代码的任何图像或详细说明场景来使这一点更加清晰。
-
我已经更新了我的问题,你能帮我吗,谢谢
-
通过您想要的输出图像,您的问题与HTML有关。也许您想在 html 表格中执行 rowspan 或 cellspan ,或者您想要使用 CSS 执行此操作,但在这两种情况下,您的问题都过于抽象;如果您可以提供reproducible example,您更有可能获得有用的答案。无论如何,您应该首先尝试编写您想要显示的最终 html 代码,然后从那里,您会发现很容易提取需要由 jQuery(或 PHP)附加的 html 部分
标签: php jquery forms dynamic-forms dynamicform