Sebastian Haug: Punktezählung

Beitrag lesen

was hast Du bisher versucht, woran ist es gescheitert?

hat er doch geschrieben

Ich würde Dir gerne helfen, weiß aber leider nicht, was Dein Problem ist.

schau einfach mal in den angegebenen Quelltext...

Also hier ist dein Problem gelöst:

Zuerst kurz was das Problem war, dann der Quelltext.
Du brauchtest einen Punktezähler - dafür habe ich die Variable "punkte" definiert.
Nun muss bei jeder korrekten Auswahl diese Variable um eins erhöht werden (punkte++) und damit gleich das Feld unten aktualisiert wird muss das Element übergeben werden und sein Wert geändert werden.
Also muss bei jedem korrekten feld in OnClick stehen:
punkte++;checkAnswer( this, winner )

Das sollte die weiterhelfen, Grüße aus München
Sebastian

<!--(C) 2003 by Tobias Sacher-->
<!-- powered by www.PCworX.net ;)-->

<html>

<title>What do you know about Schwandorf?</title>
<h1><p align="center">What do you know about Schwandorf?</p></h1><br>

<body background="http://home.nycap.rr.com/germanfriends/_themes/dmhorse/horsebk.jpg">

<p align="left"><h3> INFORMATION!</h3><h4>Please reload the page to give new answers.</h4> </p>

<font face="arial">
<body>

<script>
 function checkAnswer( ele, winner )
 {
  var rb = f[ele.name]
  for( x = 0; x < (rb.length -1); x++ )
  {
   if( !rb[x].checked )
   {
    rb[x].disabled = true
   }
  }
  rb[(rb.length-1)].value = ele.value
  winner.value=punkte
 }
 var punkte = 0
 </script>

<br>

<h2> Question 1: </h2>

<u>Where is Schwandorf?</u>
<p><a href="http://www.schwandorf.de">HELP</a></p>

<form name="f">

<input
  type=radio
  name="r1"
  value="That is right"
  onClick="punkte++;checkAnswer( this, winner )"> In Bavaria.

<br>
 <input
  type=radio
  name="r1"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> In Hessen

<br>
 <input
  type=radio
  name="r1"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> In Brandenburg

<br>
 <input
  type=radio
  name="r1"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> In Sachsen
<br>
<br>

<input
  type=text
  name="r1"
  value=""
  size= 45>

<h2> Question 2: </h2>

<u>How much population does Schwandorf have?</u>
<p><a href="http://www.schwandorf.de/showobject.phtml?object=med|292.54.1">HELP</a></p>

<input
  type=radio
  name="r2"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> More then 100 000

<br>
 <input
  type=radio
  name="r2"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Ca. 10 000

<br>
 <input
  type=radio
  name="r2"
  value="That is right"
  onClick="punkte++;checkAnswer( this, winner )"> Ca. 30 000

<br>
 <input
  type=radio
  name="r2"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Exakt 45 735
<br>
<br>
 <input
  type=text
  name="r2"
  value=""
  size= 45>

<h2> Question 3: </h2>

<u>How big is the area of Schwandorf?</u>
<p><a href="http://www.schwandorf.de/showobject.phtml?object=med|292.54.1">HELP</a></p>

<input
  type=radio
  name="r3"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Ca. 300  kilometres²

<br>
 <input
  type=radio
  name="r3"
  value="That is right"
  onClick="punkte++;checkAnswer( this, winner )"> Ca. 124 kilometres²

<br>
 <input
  type=radio
  name="r3"
  value="That is not right but it is the hole district"
  onClick="checkAnswer( this, winner )"> Ca. 1472 kilometres²

<br>
 <input
  type=radio
  name="r3"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Ca. 5000 kilometres²
<br>
<br>

<input
  type=text
  name="r3"
  value=""
  size= 45>

<h2> Question 4: </h2>

<u>What's the name of the mayor of Schwandorf?</u>
<p>
<a href="http://www.schwandorf.de/adr.phtml?call=detail&FID=269.479.1&La=1&css=">HELP</a> </p>

<input
  type=radio
  name="r4"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Konrad Adenauer

<br>
 <input
  type=radio
  name="r4"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Gerhard Schröder

<br>
 <input
  type=radio
  name="r4"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Edmund Stoiber

<br>
 <input
  type=radio
  name="r4"
  value="That is right"
  onClick="punkte++;checkAnswer( this, winner )"> Helmut Hey

<br>
<br>

<input
  type=text
  name="r4"
  value=""
  size= 45>

<h2> Question 5: </h2>

<u>Which is sight of Schwandorf?</u>
<p><a href="http://www.schwandorf.de/showobject.phtml?&object=tx|292.64.1">HELP</a></p>

<form name="f">

<input
  type=radio
  name="r5"
  value="That is right"
  onClick="punkte++;checkAnswer( this, winner )"> Blasturm

<br>
 <input
  type=radio
  name="r5"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Siegessäule

<br>
 <input
  type=radio
  name="r5"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Brandenburger Tor

<br>
 <input
  type=radio
  name="r5"
  value="That is wrong"
  onClick="checkAnswer( this, winner )"> Eifeltower
<br>
<br>

<input
  type=text
  name="r5"
  value=""
  size= 45>

<br>
<br>
<br>
<br>

<b><u> Here could you see how much points you have. For every right answer you get one of them.</u></b>

<br>
<br>

<input
  type=text
  name="winner"
  value="0"
  size= 45>

</form>

</body>
</html>