There are a couple of radio buttons initially but the user can add it any no. of time. The addition of new radio btns groups are done by jquery below. But the problem is when any of the radio btn is clicked, all the other radio btns checked are unchecked. I need to send the array of "radio_type[]" name attribute to the server. How can I do it?
Html:
<div>
<div class="registerVoucherForm">
<div class="formDetails">
<label>
<input value="pay-radio" type="radio" name="radio_type[]" checked="">
Pay
</label>
<label>
<input value="receipt-radio" type="radio" name="radio_type[]">
Receipt
</label>
</div>
</div>
<div class="addMoreFields"></div>
</div>
<a href="" class="add-new">Add New Component</a>
Jquery:
var globalIndex = 1;
$(".add-new").on("click", function (e) {
var forms = $(".formDetails").html();
var radioBtn = '<div class="formDetails addedMoreRadios_' + globalIndex + '"><hr>';
radioBtn += forms;
$(".addMoreFields").append(radioBtn);
globalIndex++;
});
P.S I tried to change the name attribute of each newly added radio btn groups but it is not working. I am not able to change the name attribute of each newly added radio btns group.
Thanks in advance.
radio_type[]name=change but doesn't post to your backend? Be explicit with what's not working.