how to checked radio false in javascript code example

Example 1: javascript uncheck radio button

document.getElementById("radioButtonID").checked = false; //uncheck a radio button
document.getElementById("radioButtonID").checked = true; //check a radio button

Example 2: javascript radio button value if checked

//alert(document.querySelector('input[name = "comp"]:checked').value);

$test=document.querySelector('input[name = "comp"]:checked').value;

if($test="silver") {
        amount=50;
    }else if($test="gold") {
      amount=90;
    }else{
      amount=30;
    }

Tags:

Html Example