Q:

javascript check radio button

function check(id) {
  document.getElementById(id).checked = true;
}
2
if(document.getElementById('gender_Male').checked) {
  //Male radio button is checked
}else if(document.getElementById('gender_Female').checked) {
  //Female radio button is checked
}
2
//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

New to Communities?

Join the community