Q:

radio button javascript

function check(id) {
  document.getElementById(id).checked = true;
}
2
function check() {
  document.getElementById("red").checked = true;
}

function uncheck() {
  document.getElementById("red").checked = false;
}
1
//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