HTMLisEasy.com
HTML tutorials for the rest of us...

 Presidential Quiz Source 

<form name="presquiz">
<table cellspacing="0" cellpadding="9" align="center" style="font:normal 10pt arial;">
<caption align="top"><font size="5"><i>A Presidential Quiz</i></font></caption>
<!--*****  Start of row 1  *****-->
<tr align="center">
<td><img src="bush2.jpg"      width="84" height="106" alt=""><br><input name="bush2"      type="radio" value="Rep">Rep<input name="bush2"      type="radio" value="Dem">Dem</td>
<td><img src="clinton.jpg"    width="84" height="106" alt=""><br><input name="clinton"    type="radio" value="Rep">Rep<input name="clinton"    type="radio" value="Dem">Dem</td>
<td><img src="bush1.jpg"      width="84" height="106" alt=""><br><input name="bush1"      type="radio" value="Rep">Rep<input name="bush1"      type="radio" value="Dem">Dem</td>
<td><img src="reagan.jpg"     width="84" height="106" alt=""><br><input name="reagan"     type="radio" value="Rep">Rep<input name="reagan"     type="radio" value="Dem">Dem</td>
<td><img src="carter.jpg"     width="84" height="106" alt=""><br><input name="carter"     type="radio" value="Rep">Rep<input name="carter"     type="radio" value="Dem">Dem</td>
<td><img src="ford.jpg"       width="84" height="106" alt=""><br><input name="ford"       type="radio" value="Rep">Rep<input name="ford"       type="radio" value="Dem">Dem</td>
</tr>
<!--*****  Start of row 2  *****-->
<tr align="center">
<td><img src="nixon.jpg"      width="84" height="106" alt=""><br><input name="nixon"      type="radio" value="Rep">Rep<input name="nixon"      type="radio" value="Dem">Dem</td>
<td><img src="johnson.jpg"    width="84" height="106" alt=""><br><input name="johnson"    type="radio" value="Rep">Rep<input name="johnson"    type="radio" value="Dem">Dem</td>
<td><img src="kennedy.jpg"    width="84" height="106" alt=""><br><input name="kennedy"    type="radio" value="Rep">Rep<input name="kennedy"    type="radio" value="Dem">Dem</td>
<td><img src="eisenhower.jpg" width="84" height="106" alt=""><br><input name="eisenhower" type="radio" value="Rep">Rep<input name="eisenhower" type="radio" value="Dem">Dem</td>
<td><img src="truman.jpg"     width="84" height="106" alt=""><br><input name="truman"     type="radio" value="Rep">Rep<input name="truman"     type="radio" value="Dem">Dem</td>
<td><img src="roosevelt.jpg"  width="84" height="106" alt=""><br><input name="roosevelt"  type="radio" value="Rep">Rep<input name="roosevelt"  type="radio" value="Dem">Dem</td>
</tr>
<!--*****  Answer button  *****-->
<tr align="center">
<td colspan="6"><input type="button" value="Click here to check your answers" onClick="isThatYourFinalAnswer();"></td>
</tr>
</table>
</form>

Below is the Javascript that powers the quiz...

/************************************************************\
 Presidential Quiz by Joe Barta - HTMLisEasy.com
 Permission is granted to freely use/modify this code.
\************************************************************/

function isThatYourFinalAnswer()
{
   var incorrect_answers = 0;
   var hint_pieces = "";

   if ((window.document.presquiz.elements[0].checked  == false)||(window.document.presquiz.elements[1].checked  == true )) { incorrect_answers++; hint_pieces = hint_pieces + "George W. Bush is a Republican\n"; }
   if ((window.document.presquiz.elements[2].checked  == true )||(window.document.presquiz.elements[3].checked  == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Bill Clinton was a Democrat\n"; }
   if ((window.document.presquiz.elements[4].checked  == false)||(window.document.presquiz.elements[5].checked  == true )) { incorrect_answers++; hint_pieces = hint_pieces + "George H.W. Bush was a Republican\n"; }
   if ((window.document.presquiz.elements[6].checked  == false)||(window.document.presquiz.elements[7].checked  == true )) { incorrect_answers++; hint_pieces = hint_pieces + "Ronald Reagan was a Republican\n"; }
   if ((window.document.presquiz.elements[8].checked  == true )||(window.document.presquiz.elements[9].checked  == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Jimmy Carter was a Democrat\n"; }
   if ((window.document.presquiz.elements[10].checked == false)||(window.document.presquiz.elements[11].checked == true )) { incorrect_answers++; hint_pieces = hint_pieces + "Gerald Ford was a Republican\n"; }
   if ((window.document.presquiz.elements[12].checked == false)||(window.document.presquiz.elements[13].checked == true )) { incorrect_answers++; hint_pieces = hint_pieces + "Richard Nixon was a Republican\n"; }
   if ((window.document.presquiz.elements[14].checked == true )||(window.document.presquiz.elements[15].checked == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Lyndon Johnson was a Democrat\n"; }
   if ((window.document.presquiz.elements[16].checked == true )||(window.document.presquiz.elements[17].checked == false)) { incorrect_answers++; hint_pieces = hint_pieces + "John F. Kennedy was a Democrat\n";}
   if ((window.document.presquiz.elements[18].checked == false)||(window.document.presquiz.elements[19].checked == true )) { incorrect_answers++; hint_pieces = hint_pieces + "Dwight Eisenhower was a Republican\n"; }
   if ((window.document.presquiz.elements[20].checked == true )||(window.document.presquiz.elements[21].checked == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Harry Truman was a Democrat\n"; }
   if ((window.document.presquiz.elements[22].checked == true )||(window.document.presquiz.elements[23].checked == false)) { incorrect_answers++; hint_pieces = hint_pieces + "Franklin Roosevelt was a Democrat\n";}//Herbert Hoover was a Republican\n

   var hint1 = "Here is a hint...\n\n"      + hint_pieces + "\nAdjust your answers and click the link again";
   var hint2 = "Here are a couple hints...\n\n" + hint_pieces + "\nAdjust your answers and click the link again";
   var hint3 = "Here are a few hints...\n\n"    + hint_pieces + "\nAdjust your answers and click the link again";

   if((window.document.presquiz.elements[0].checked  == false)&&(window.document.presquiz.elements[1].checked  == false)&&(window.document.presquiz.elements[2].checked  == false)&&(window.document.presquiz.elements[3].checked  == false)&&(window.document.presquiz.elements[4].checked  == false)&&(window.document.presquiz.elements[5].checked  == false)&&(window.document.presquiz.elements[6].checked  == false)&&(window.document.presquiz.elements[7].checked  == false)&&(window.document.presquiz.elements[8].checked  == false)&&(window.document.presquiz.elements[9].checked  == false)&&(window.document.presquiz.elements[10].checked  == false)&&(window.document.presquiz.elements[11].checked  == false)&&(window.document.presquiz.elements[12].checked  == false)&&(window.document.presquiz.elements[13].checked  == false)&&(window.document.presquiz.elements[14].checked  == false)&&(window.document.presquiz.elements[15].checked  == false)&&(window.document.presquiz.elements[16].checked  == false)&&(window.document.presquiz.elements[17].checked  == false)&&(window.document.presquiz.elements[18].checked  == false)&&(window.document.presquiz.elements[19].checked  == false)&&(window.document.presquiz.elements[20].checked  == false)&&(window.document.presquiz.elements[21].checked  == false)&&(window.document.presquiz.elements[22].checked  == false)&&(window.document.presquiz.elements[23].checked  == false))
   {
      alert("You\'re not even gonna try? At least click a thing or two.");
   }
   else
   {
      if(incorrect_answers == 0)
      {
         alert("All correct. Very good!");
      }

      if(incorrect_answers == 1)
      {
         if (confirm("Doh! Missed one. Still, not bad. Would you like some help?"))
         {
            alert(hint1)
         }
      }

      if(incorrect_answers == 2)
      {
         if (confirm("Bummer. Missed two. Would you like some help?"))
         {
            alert(hint2)
         }
      }

      if((incorrect_answers == 3)||(incorrect_answers == 4)||(incorrect_answers == 5)||(incorrect_answers == 6)||(incorrect_answers == 7)||(incorrect_answers == 8))
      {
         if (confirm("Missed a few. Would you like some help?"))
         {
            alert(hint3)
         }
      }

      if(incorrect_answers > 8)
      {
         if (confirm("Oh my. You didn\'t do so well. Would you like some help?"))
         {
            alert(hint3)
         }
      }
   }
}
Form Tutor
Lessons: Intro 1 2 3 4 5 6 7 8 9 10 11 12 13      Quick Forms Reference
HTML 4.0 Reference      Barebones HTML Guide