I need one help. I need to check the radio button dynamically using Javascript/Jquery. I am explaining my code below.
<div style="float:left; margin-right:10px;">
<input type="radio" name="answer_type0" id="answer_type0" onclick="selectScale(this.value,'0');" value="5736db13ed8cda709ffc8918">Scale
<input type="radio" name="answer_type0" id="answer_type0" onclick="selectScale(this.value,'0');" value="5736daffed8cda709ffc8917">Yes/No
<input type="radio" name="answer_type0" id="answer_type0" onclick="selectScale(this.value,'0');" value="5736db29ed8cda709ffc8919">Written
</div>
<span>
<button type="button" id="btn" name="btn" onclick="setRadioButtonValue()">Set</button>
</span>
Here 3 radio button are available .When user will click on set button one radio button should be checked as per given value. My javascript code is given below.
function setRadioButtonValue(){
var valu="5736daffed8cda709ffc8917";
$('#answer_type0').val(valu).prop('checked', true);
console.log('check',document.getElementById('answer_type0').checked);
}
My updated code are available here
Here i need to check as per the given value(i.e-var valu="5736daffed8cda709ffc8917"
) so as per code the Yes/No
should be checked but in my case the first radio button always checked.Please help me to resolve this issue.similarly i need to also check the multiple set of radio button from each set. My plunkr code is here.