David Hörpel: Hilfestellung zu Script

Beitrag lesen

Hallo!

Ich habe ein ganz einfach gestricktes Script für eine Auswertung (richtig/falsch) programmiert. Im folgenden Code, wird das Script trotz for-Schleife nach dem ersten if-Block unterbrochen:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Unbenanntes Dokument</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="1" height="200"> </td>
    <td width="100%" valign="top">
 <script language="JavaScript" type="text/javascript">

var   a = "schröder";
       b = "anwendungssoftware";
    c = "bild";

document.open();
     function Ergebnis()
  {

for (i=0; i<=2; i++) {

if (document.form1.form1[0].checked == true)
  document.writeln("Ihre Antwort " +a+ " ist richtig!")
  else if (document.form1.form1[1].checked == true)
  document.writeln("Ihre Antwort " +document.form1.form1[1].value+ " ist leider falsch!")
     else (document.form1.form1[2].checked == true)
  document.writeln("Ihre Antwort " +document.form1.form1[2].value+ " ist leider falsch!")

if (document.form2.form2[0].checked == true)
  document.writeln("Ihre Antwort " +b+ " ist richtig!")
  else if (document.form2.form2[1].checked == true)
  document.writeln("Ihre Antwort " +document.form2.form2[1].value+ " ist leider falsch!")
     else (document.form2.form2[2].checked == true)
  document.writeln("Ihre Antwort " +document.form2.form2[2].value+ " ist leider falsch!")

if (document.form3.form3[0].checked == true)
  document.writeln("Ihre Antwort " +c+ " ist richtig!")
  else if (document.form3.form3[1].checked == true)
  document.writeln("Ihre Antwort " +document.form2.form2[1].value+ " ist leider falsch!")
     else (document.form3.form3[2].checked == true)
  document.writeln("Ihre Antwort " +document.form3.form3[2].value+ " ist leider falsch!")

}

}
  document.close();

document.open();
  document.writeln("<p>Wie heisst der Bundeskanzler?</p><form name='form1' method='post' action=''><p> <input type='radio' name='form1' value='schröder'>Schröder</p><p> <input type='radio' name='form1' value='kohl'>Kohl </p><p><input type='radio' name='form1' value='schmidt'>Schmidt </p></form><p>Was für Software stellt SAP her?</p><form name='form2' method='post' action=''><p> <input type='radio' name='form2' value='anwendungssoftware'>Anwendungssoftware</p><p><input type='radio' name='form2' value='entwicklersoftware'>Entwicklersoftware</p><p><input type='radio' name='form2' value='privatanwender'>Software für den Privatanwender</p></form><p>Welche Zeitung wird in Deutschland am Meisten gelesen?</p><form name='form3' method='post' action=''><p><input type='radio' name='form3' value='bild'>Bild</p><p><input type='radio' name='form3' value='süddeutsche'>Süddeutsche</p>")
  document.writeln("<p><input type='radio' name='form3' value='faz'>FAZ </p><br><input type='button' name='button' onClick='Ergebnis()' value='Abschicken'></form>");
     document.close();
</script>
      <p> </p>
      </td>
  </tr>
</table>
</body>
</html>

Kann mir einer sagen, wieso? Danke!

Gruß David!