I try to make a dynamic input form group to add extra rows. Adding rows in the input group works!
Now I would like to send a variable back with the number of rows. I have a working for loop that counts the rows. But the variable stays the same.
$(document).ready(function(){
var max_fields = 16;
var add_input_button = $('.add_input_button');
var field_wrapper = $('.field_wrapper');
var input_count = 4;
var new_field_html = // html code with input_count(works but stays on 4)
// Add button dynamically
$(add_input_button).click(function(){
if(input_count < max_fields){
input_count++;
console.log(input_count);
$(field_wrapper).append(new_field_html);
}
});
I can see in my console log the correct loop!
How can I change the code to update the input_count on return value? screenshot of the problem

new_field_htmlvariable in yourclickcallback function