0
The script below adds groups of fields in a form. So far ok. Fields are added but when I send the form I only receive data from fixed inputs, which are added dynamically are not received.
Code:
$(document).ready(function() {
var max_fields = 100; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var token = $('#token').val();
var x = 1; //initlal text box count
$(add_button).on({click: function(e){ //on add input button click
e.preventDefault();
var length = wrapper.find("input:text").length;
if (x < max_fields) { //max input box allowed
x++; //text box increment
$(wrapper).append('ADD INPUTS'); //add input box
}
wrapper.find("input:hidden").each(function() {
$(this).val()
});
$(function (){
$('.select2').select2()
});
}});
$(wrapper).on("click", ".remove_field", function(e) { //user click on remove text
e.preventDefault();
$(this).parent('div').remove();
x--;
})
});