I want to change the value of a radio button programatically on a website built on Spring, with jQuery on the frontend.
I’ve managed to change other values, but the radio button is kind of tricky.
Here’s the HTML for the button:
<table id="formCheltuialaBuget:radioTVA" role="presentation" class="ui-selectoneradio ui-widget">
<tbody>
<tr>
<td>
<div class="ui-radiobutton ui-widget">
<div class="ui-helper-hidden-accessible"><input id="formCheltuialaBuget:radioTVA:0"
name="formCheltuialaBuget:radioTVA" type="radio" value="true"
onchange="PrimeFaces.ab({s:"formCheltuialaBuget:radioTVA",e:"change",p:"formCheltuialaBuget:radioTVA",u:"formCheltuialaBuget:tvaelig formCheltuialaBuget:totalELigg formCheltuialaBuget:publicBuget formCheltuialaBuget:tvanonelig formCheltuialaBuget:contributie",onst:function(cfg){document.body.style.cursor='wait';},onco:function(xhr,status,args){document.body.style.cursor='default';}});"
wtx-context="F08D1A11-AFD1-4F6C-80FC-F02488900FAB"></div>
<div class="ui-radiobutton-box ui-widget ui-corner-all ui-state-default"><span
class="ui-radiobutton-icon ui-icon ui-icon-blank ui-c"></span></div>
</div>
</td>
<td><label for="formCheltuialaBuget:radioTVA:0">Da</label></td>
<td>
<div class="ui-radiobutton ui-widget">
<div class="ui-helper-hidden-accessible"><input id="formCheltuialaBuget:radioTVA:1"
name="formCheltuialaBuget:radioTVA" type="radio" value="false"
onchange="PrimeFaces.ab({s:"formCheltuialaBuget:radioTVA",e:"change",p:"formCheltuialaBuget:radioTVA",u:"formCheltuialaBuget:tvaelig formCheltuialaBuget:totalELigg formCheltuialaBuget:publicBuget formCheltuialaBuget:tvanonelig formCheltuialaBuget:contributie",onst:function(cfg){document.body.style.cursor='wait';},onco:function(xhr,status,args){document.body.style.cursor='default';}});"
checked="checked" wtx-context="3412B572-AE39-4A78-B34C-87A13760C805"></div>
<div class="ui-radiobutton-box ui-widget ui-corner-all ui-state-default ui-state-active"><span
class="ui-radiobutton-icon ui-icon ui-icon-bullet ui-c"></span></div>
</div>
</td>
<td><label for="formCheltuialaBuget:radioTVA:1">Nu</label></td>
</tr>
</tbody>
</table>
How can I change the value of the radio button to true/false?
Changing it this way:
document.getElementById("formCheltuialaBuget:radioTVA:0").value = false;
document.getElementById("formCheltuialaBuget:radioTVA:1").value = true;
didn’t do it anything.
Thanks!