Problem about coding in ajvascript
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?
View Answers
June 11, 2012 at 4:17 PM
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>
June 12, 2012 at 11:55 AM
Thank You MY friend. It worked great for me.
Ads
Related Tutorials/Questions & Answers:
Problem about coding in ajvascript
Problem about coding in ajvascript 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 />
problem in coding
problem in coding i have a following code which display the contents of the text file but not other program like java or any c program is there any handler to open the program files other than Filereader.
FileReader fr = new
Advertisements
problem i coding
problem i coding i have a
problem in
coding a combobox containing a number of *.java program on click one of them that program should compile and run and display the result in other window
Please provide the coding for this problem
Please provide the
coding for this problem Please provide the
coding for the following
problem. Write a "hangman" game that randomly generates a word and prompts the user to guess one letter at a time. Each letter in the word
about .net coding
about .net coding please suggest me the code used for viewing a page in .net language
Please provide coding for following problem
Please provide
coding for following problem Please provide the
coding for the following
problem:
You will write a java program that will read data from a file. The data in the file will be:
John Doe 75
Joe Blow 65
Mary Smith 80
problem in writing coding. Please help me.
problem in writing
coding. Please help me. Hi sir, my name is Logeswaran. I have
problem in writing JSP
coding for my university assigments. Actually I'm doing a Voting System. I need to know how to write JSP
coding
problem to do coding upload image in php
problem to do
coding upload image in php can i get example
coding how to upload image in php?i have try it but i dont no wheter it is correct or not because i can't save the image in folder and not connected to database mysql
coding
coding I need the logout
coding. can you please help me.
Please visit the following links:
http://www.roseindia.net/quickguide/tomcat/Logout.shtml
http://www.roseindia.net/jsp/loginstatus.shtml
program coding
program coding how to rearrange the array a[1]. . a[n] even elements and odd elements? please give the example
coding program.please provide the
coding for this
problem
Problem
(UnknownHostException e)
{
System.err.println("Don't know
about host
Problem
)
{
System.err.println("Don't know
about host: sunil-PC.");
System.exit(1
coding for project
coding for project hai
how to write jsp
coding for project smart accessories ......
that s to navigate to another page when you click on a tag
Medical coding training
Medical
coding training Hi,
What is Medical
coding training course? How anyone can make career in Medical
coding training?
Thanks
Hi,
Medical
coding training can be a good career for any graduate. It's one
Java Coding
Java Coding Hello, Can u please tel me how to improve my
coding techniques.I am feeling difficulty with
coding but I am perfect with my theory part
coding for chart
coding for chart I want to convert a character into binary then convert it into its diagram in form of digital electrical signals.How can I do java
coding for this diagram
coding of button
coding of button What is code of fetching the value of button in a textbox using javascript
What is the future of coding?
What is the future of
coding? Hi,
Where we are going? What is the future of
coding in near future?
Thanks
Hi,
In future we going to write code
about:
Business intelligence and Machine learning
The Big Data
program coding
program coding how to rearrange the array a[1]. . a[n] even elements and odd elements? please give the example
coding program
coding C
coding C Write a program for a GENERAL NUMBER CONVERTERS which include
binary, decimal, octa and hexadecimal. You need to write the program using C
language