I have radio buttons in my code and want them to update like the other variables on the web page when their state is changed
HTML
<TD><Input id="radOn2" name="Nb_var86" type= "radio" Value=1 onClick="this.form.submit();">ON</TD>
<TD><Input id="radOff2" name="Nb_var86" type= "radio" Value=0 onClick="this.form.submit();">OFF</TD>
JavaScript
var timeout;
function bloop() {
$.ajax({
url: "/ajax.html",
success:function(result){
var array=result.split(',');
for(i=0;i<array.length;i++){
$("input[name='Nb_var"+array[i].substring(0,array[i].indexOf(':'))+"']").val(array[i].substring(array[i].indexOf(':')+1));
}
}
});
timeout = window.setTimeout(function(){bloop()}, 4000);
}
For the life of me I cannot figure out why the radio buttons wont update. Any help is appreciated.
I have attempted the other examples found in Stack overflow, they did not seem to work. My bloop function updates a list of variables on the web page but the radio buttons (variables in the list) do not get updated unless you refresh the page. I would like to have jquery update the radio button status without refreshing the page
Here is what I have tried : I can see the var on the page so I know that the server and ajax are updating the var:
<TD><Input id="radOn2" name="Nb_var86" type= "radio" Value=1 onClick="this.form.submit();">ON</TD>
<TD><Input id="radOff2" name="Nb_var86" type= "radio" Value=0 onClick="this.form.submit();">OFF<input readonly name= "Nb_var86"style="font-size: 105%;border:none;" value ="<Nb_var86>" size = 2></TD>
then in the script I have tried all of these but no luck actually flipping the radio button:
if($("input[name=Nb_var86]:checked").val()==1){
$('input:radio[name=Nb_var86][id=radon2]').click();
//$("#radon2").prop("checked", "checked");
//$('input:radio[name = Nb_var86]').val(['radon2']);
//$('#radon2').attr('checked', 'checked');
//$("input[name = Nb_var86] [id = radon2]").prop('checked', true);
//$("#radoff2").prop("checked", false).val()==0;
//$("#radon2").prop("checked", true).val()==1;
Am I missing something?