+ 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 ?

5th Apr 2017, 5:56 PM
Nour Rihan
Nour Rihan - avatar
3 Réponses
+ 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; } }
5th Apr 2017, 6:41 PM
Benneth Yankey
Benneth Yankey - avatar
5th Apr 2017, 6:30 PM
Luca Garrera
0
Thank you guys
6th Apr 2017, 5:58 PM
Nour Rihan
Nour Rihan - avatar