+ 1
How can I get the choice of the user input by radio in JavaScript?
I wrote a code which you have to only answer by one choice (radio) from 3 choices and I want to know what the user have entered to do some calculations but I don't know how to take the user's Input ?
3 Respostas
+ 5
<input class="msgCheckBox" type="checkbox" value="1">
// for single input
var checkedBox = document.getElementsByClassName('msgCheckBox').checked
// loop through more than one input
var checkedBox;
var inputElems = document.getElementsByClassName('msgCheckBox');
for(var i=0; i < inputElems.length; i++) {
if(inputElems[i].checked){
checkedBox = inputElems[i].value;
break;
}
}
0
Thank you guys