You create a data-hid for the button here:
var hid = "hidden" + id + n + "value"; $(btn).attr("data-hid", hid);
based on this, you now generate an input field:
var input = '<input type="text" id="' + hid + '" value="' + value + '" name="' + id + 'value" />';
The identification variable in this case is the identifier of the button, which will be, for example, answerC . Thus, the first time you click the button, you will hide #hiddenanswerC0value .
However, when you add a response, the buttons will have an identifier generated as follows:
.attr('id', $this.attr('id')+'Row');
Thus, an additional Row will be added at the end. So the data-hid and input field will also be different ( #hiddenanswerCRow0value ).
Edit: Another problem is that you are not actually creating hidden data for the new buttons. You create it only for the first set of buttons after clicking on them. But when you create a second set (after pressing) with the C button already activated, it will not have the data-hid parameter set and, therefore, you cannot delete it.
aKzenT
source share