I'm new on javascript coding.
I'm kinda creating a survey page by myself. I will ask question as a 'True or False' and will get True as a 1 point, false as a 0 point. there will be multiple questions.
I tried to do it by getElementsByName but it didn't worked. my code is like that. can anyone help me please?
<form>
<input type="radio" name="question1" value="1" id="q1"> true
<input type="radio" name="question1" value="0" id="q1"> false
</form>
<button onclick="myFunction()">try</button>
<script>
function myFunction()
{
var x=document.getElementsByName("question1").value;
window.alert("your score is " +x);
}
</script>
IDof radio buttons..IDhas to be unique. Giveq1andq2asID's