
I created a three radio buttons in the following way
How many iphone styles are present in the image?
<input type="radio" name="option" id="option" value="01" /> 01<br />
<input type="radio" name="option" id="option" value="03" /> 03<br />
<input type="radio" name="option" id="option" value="05" /> 05<br />
<input type="button" value="submit" onclick="javascript:checkAnswer()"/><br/>
In the above options one option is correct . if we select one radio button and click on submit I should get whether the option selected is true or false. Can please help me in getting a code using javascript please?

Here is an example of JavaScript radiobutton. The given code allow the user to select any radio button. If the selected radio button value matches with the supposed answer, it will display true message, otherwise it will return false message. We have made the option 2 as correct answer.
<html>
<head>
<script language = "JavaScript">
function checkAnswer(selObject) {
var value = null
for (var i=0; i<selObject.length; i++) {
if (selObject[i].checked) {
value = selObject[i].value;
break ;
}
}
var correctAns='03';
if(correctAns==value){
alert("true");
}
else{
alert("false");
}
}
</script>
</head>
<body>
<form name="form1">
<input type="radio" name="option" value="01">01<br>
<input type="radio" name="option" value="03">03<br>
<input type="radio" name="option" value="05">05<br>
<input type="button" value="submit" onClick="checkAnswer(this.form.option);">
</form>
</body>
</html>

Thank You MY friend. It worked great for me.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.