I'm trying to implement a button to add extra fields, in which case I'm creating an activity report where it contains 5 fields. When the button is clicked it adds another 5 of those same field.
I currently have:
JavaScript
$(function () {
var scntDiv = $('#dynamicDiv');
$(document).on('click', '#addInput', function () {
$('<p>'+
'<input type="text" id="inputeste" size="20" value="" placeholder="" /> '+
'<a class="btn btn-danger" href="javascript:void(0)" id="remInput">'+
'<span class="glyphicon glyphicon-minus" aria-hidden="true"></span> '+
'</a>'+
'</p>').appendTo(scntDiv);
return false;
});
$(document).on('click', '#remInput', function () {
$(this).parents('p').remove();
return false;
});
});
HTML
<div id="dynamicDiv"></div>
As I return several days, and every day there may be N tasks, when I click add fields, only the first day is added, being that every day I have a button.
EDIT 1:
In my case, I have dynamically generated days, and every day I have a button to add, when to on day 21 for example and I click add, it is added normally because it is my first field, day 22 and click to add it adds the fields in the panel of the 21st.
How do I know which day to add?