Q:

javascript radio button value if checked

if(document.getElementById('gender_Male').checked) {
  //Male radio button is checked
}else if(document.getElementById('gender_Female').checked) {
  //Female radio button is checked
}
2
function check() {
  document.getElementById("red").checked = true;
}

function uncheck() {
  document.getElementById("red").checked = false;
}
1
//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;
    }
0
//Creates a radio button
var radioInput = document.createElement('input');
radioInput.setAttribute('type', 'radio');
radioInput.setAttribute('name', name);
document.body.appendChild(radioInput); //Adds the button to the DOM

//Select all radio buttons on page
var radioButtons = document.querySelectorAll('input[type="radio"]');
-1
$('#myForm input').on('change', function() {
   alert($('input[name=radioName]:checked', '#myForm').val()); 
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form id="myForm">
  <input type="radio" name="radioName" value="1" /> 1 <br />
  <input type="radio" name="radioName" value="2" /> 2 <br />
  <input type="radio" name="radioName" value="3" /> 3 <br />
</form>
0

New to Communities?

Join the community