Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
添加更多按钮html php的问题_Php_Jquery - Fatal编程技术网

添加更多按钮html php的问题

添加更多按钮html php的问题,php,jquery,Php,Jquery,$(文档).ready(函数(){ var i=1; $('#添加')。单击(函数(){ i++; $(“#动态_字段”).append('X'); }); $(文档).on('click','btn_remove',函数(){ var按钮_id=$(this.attr(“id”); $(“#行”+按钮id+”).remove(); }); }); 添加更多 接近 提交 我已经测试了您的代码,它对我来说运行良好 重要提示:-我已经在一个页面上添加了完整的代码。(我只在页面上添加了这么多代码,没

$(文档).ready(函数(){
var i=1;
$('#添加')。单击(函数(){
i++;
$(“#动态_字段”).append('X');
});
$(文档).on('click','btn_remove',函数(){
var按钮_id=$(this.attr(“id”);
$(“#行”+按钮id+”).remove();
});
});

添加更多
接近
提交

我已经测试了您的代码,它对我来说运行良好

重要提示:-我已经在一个页面上添加了完整的代码。(我只在页面上添加了这么多代码,没有其他内容。)

form.php:-


添加更多
接近
提交
$(文档).ready(函数(){
var i=1;
$('#添加')。单击(函数(){
i++;
$(“#动态_字段”).append('X');
});
$(文档).on('click','btn_remove',函数(){
var按钮_id=$(this.attr(“id”);
$(“#行”+按钮id+”).remove();
});
});

输出:-和

如何获得阵列?使用类而不是ID。ID应该是唯一的。您是否使用ajax提交表单?@HimanshuUpadhyay nop just noraml form submitOk所以您使用php打印变量?来自$\u POST?@Rupal不,你错了。查看我的评论屏幕截图
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="" method="POST" id="form1" />
    <div class="form-group">

      <div class="table-responsive">
        <table class="table table-bordered" id="dynamic_field">
          <tr>
            <td><input type="text" name="actions[]" placeholder="Action Items" class="form-control name_list" /></td>

            <td><button type="button" name="add" id="add" class="btn btn-success">Add More</button></td>
          </tr>
        </table>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="submit" name="submitabouc" id="i_submit" class="btn btn-success">Submit</button>
      </div>
</form>
<script>
 $(document).ready(function() {
      var i = 1;
      $('#add').click(function() {
        i++;
        $('#dynamic_field').append('<tr id="row' + i + '"><td><input type="text" name="actions[]" placeholder="Action items" class="form-control name_list" /></td><td><button type="button" name="remove" id="' + i + '" class="btn btn-danger btn_remove">X</button></td></tr>');
      });
      $(document).on('click', '.btn_remove', function() {
        var button_id = $(this).attr("id");
        $('#row' + button_id + '').remove();
      });

    });
</script>

<?php

if(isset($_POST['submitabouc'])){
   echo "<pre/>";print_r($_POST);
}

?>