Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple radio button group form submit

Status
Not open for further replies.

chriscant

Technical User
Oct 24, 2007
4
GB
Hi guys i need some advice on how to get my javascript running correctly

I have a large HTML radio button form with multiple radio button groups (40 groups 4 radio buttons per group), i have a javascript funtion which will check the radio buttons once the submit button is pressed however the code never gets past the first radio button, i dont know how to change the code so that it will display all the results from the quiz.
Any help would be greatly appreciated


The code i got for the radio buttons is as follows

<label>
<input type="radio" name="question40" value="answer1">
links</label>
<br/>
<label>
<input type="radio" name="question40" value="answer2">
e-mail</label>
<br/>
<label>
<input type="radio" name="question40" value="answer3">
favourites</label>
<br/>
<label>
<input type="radio" name="question40" value="answer4">
forward-back</label>

the code for the javascript is as follows

<script type = "text/JavaScript">
function checkAnswers() {
if(form1.question1[0].checked){
document.write("Question 1 = Correct")
}
else{
document.write("Question 1 = Incorrect")
}
if(form1.question2[3].checked){
document.write("Question2 = Correct")
}
else{
document.write("Question 2 = Incorrect")
}
}

</script>

obviously not complete yet as i cant get past the first radio button
 
try writing to the innerhtml of a div, instead of using document.write
Code:
document.getElementById("yourdivid").innerHTML+="Question 1 = Incorrect<br>"
 
if i posted my full code i can imagin gettin told off because the code is over 1000 lines long...its a big qiz hehe :S but i'll give that a try
 
sadly that did not work it just skipped my first if entirely
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top