Avatar billede kalkunen Nybegynder
28. august 2001 - 15:47 Der er 3 kommentarer og
1 løsning

Quiz System

Jeg har denne Java Script Quiz, som jeg har fundet!
Her er koden:
<script>
/* GameQuiz v1.0 by Monichar.
  Copyright (c) of Monichar, 1997.
  Permission to use, edit, etc. granted as long as the head section is intact!
*/

var ans = new Array;
var done = new Array;
var score = 0;


ans[1] = \"c\";
ans[2] = \"a\";
ans[3] = \"b\";
ans[4] = \"b\";
ans[5] = \"d\";
ans[6] = \"c\";
ans[7] = \"c\";
ans[8] = \"c\";
ans[9] = \"d\";
ans[10] = \"a\";

function Engine(question, answer) {

    if (answer != ans[question]) {
        if (!done[question]) {
            done[question] = -1;
            alert(\"Wrong!\\n\\nYour score is now: \" + score);
                }
        else {
            alert(\"You have already answered that!\");
            }
        }
    else {
        if (!done[question]) {
            done[question] = -1;
            score++;
            alert(\"Correct!\\n\\nYour score is now: \" + score);
                }
        else {       
            alert(\"You have already answered that!\");
            }
        }
}
       
function NextLevel () {
    if (score > 10) {
        alert(\"Cheater!\");
        }
    if (score >= 7 && score <= 11) {
        alert(\"Access permitted!  But there are no more levels if you don\'t make any ...\")
        //self.location=\"GameQuiz2.htm\"
        }
    else {
        alert(\"Access denied!  You need 7 points to enter the next level.\")
        }
}


</script>
<BODY BGCOLOR=\"#FFFFFF\">
<center><font size=6 face=Arial>Game Quiz</font><br>
</center><p>
This script will automatically check your answers for you.
See how good you are at these gaming questions; if you get
more than seven, move on to the 2nd round!<p>

<b>Objective: answer 7 questions correctly.  JavaScript required!</b><p>
<noscript>JavaScript is <b><i>disabled</b></i>.  Get Netscape 3.0 or turn it on!</noscript>

<form>
<b>1. WARM-UP: Who created the famous <i>WarCraft 2</i>?</b><p>
<input type=radio value=\"a\" onClick=\"Engine(1, this.value)\">Sierra On-Line<br>
<input type=radio value=\"b\" onClick=\"Engine(1, this.value)\">BlueByte<br>
<input type=radio value=\"c\" onClick=\"Engine(1, this.value)\">Blizzard Entertainment<br>
<input type=radio value=\"d\" onClick=\"Engine(1, this.value)\">Microsoft<p>

<b>2. This famous 3D shooter claimed <i>PC Gamer\'s</i> Game of 1994 Award.</b><p>
<input type=radio value=\"a\" onClick=\"Engine(2, this.value)\">Doom<br>
<input type=radio value=\"b\" onClick=\"Engine(2, this.value)\">Hexen<br>
<input type=radio value=\"c\" onClick=\"Engine(2, this.value)\">Descent<br>
<input type=radio value=\"d\" onClick=\"Engine(2, this.value)\">Wolfenstein 3D<p>

<b>3. The first intergalatic combat game.  Name it.</b><p>
<input type=radio value=\"a\" onClick=\"Engine(3, this.value)\">Master of Orion<br>
<input type=radio value=\"b\" onClick=\"Engine(3, this.value)\">Star Control<br>
<input type=radio value=\"c\" onClick=\"Engine(3, this.value)\">StarCraft<br>
<input type=radio value=\"d\" onClick=\"Engine(3, this.value)\">Star Trek<p>

<b>4. The game ever to contain graphics was this classic by Roberta Williams.</b><p>
<input type=radio value=\"a\" onClick=\"Engine(4, this.value)\">King\'s Quest<br>
<input type=radio value=\"b\" onClick=\"Engine(4, this.value)\">Mystery House<br>
<input type=radio value=\"c\" onClick=\"Engine(4, this.value)\">Time Zone<br>
<input type=radio value=\"d\" onClick=\"Engine(4, this.value)\">Mission: Asteriod<p>

<b>5. The first real-time strategy game was: </b><p>
<input type=radio value=\"a\" onClick=\"Engine(5, this.value)\">WarCraft: Orcs & Humans<br>
<input type=radio value=\"b\" onClick=\"Engine(5, this.value)\">Command & Conquer<br>
<input type=radio value=\"c\" onClick=\"Engine(5, this.value)\">Dune<br>
<input type=radio value=\"d\" onClick=\"Engine(5, this.value)\">Dune 2<p>

<b>6. In PC Gamer, Quake won these \'of-the-year\' awards (1996): </b><p>
<input type=radio value=\"a\" onClick=\"Engine(6, this.value)\">Best Game, Best Action Game<br>
<input type=radio value=\"b\" onClick=\"Engine(6, this.value)\">Best Action Game, Best Multiplayer<br>
<input type=radio value=\"c\" onClick=\"Engine(6, this.value)\">Best Sound Effects, Best Multiplayer<br>
<input type=radio value=\"d\" onClick=\"Engine(6, this.value)\">All of the above<p>

<b>7. The best selling game of all time is: </b><p>
<input type=radio value=\"a\" onClick=\"Engine(7, this.value)\">WarCraft 2<br>
<input type=radio value=\"b\" onClick=\"Engine(7, this.value)\">C&C: Red Alert<br>
<input type=radio value=\"c\" onClick=\"Engine(7, this.value)\">Sim City<br>
<input type=radio value=\"d\" onClick=\"Engine(7, this.value)\">King\'s Quest 5<p>

<b>8. This is a turn-based strategy game: </b><p>
<input type=radio value=\"a\" onClick=\"Engine(8, this.value)\">C&C: Red Alert<br>
<input type=radio value=\"b\" onClick=\"Engine(8, this.value)\">Might and Magic 3<br>
<input type=radio value=\"c\" onClick=\"Engine(8, this.value)\">Heroes of Might and Magic<br>
<input type=radio value=\"d\" onClick=\"Engine(8, this.value)\">Daggerfall: The Elder Scrolls<p>

<b>9. PC Gamer\'s <i>Best Game of the 1996</i> went to: </b><p>
<input type=radio value=\"a\" onClick=\"Engine(9, this.value)\">C&C: Red Alert<br>
<input type=radio value=\"b\" onClick=\"Engine(9, this.value)\">Tomb Raider<br>
<input type=radio value=\"c\" onClick=\"Engine(9, this.value)\">Quake<br>
<input type=radio value=\"d\" onClick=\"Engine(9, this.value)\">Civilization 2<p>

<b>10. Blizzard\'s new release, <i>Diablo</i> is a: </b><p>
<input type=radio value=\"a\" onClick=\"Engine(10, this.value)\">Role Playing Game<br>
<input type=radio value=\"b\" onClick=\"Engine(10, this.value)\">2D Action Game<br>
<input type=radio value=\"c\" onClick=\"Engine(10, this.value)\">3D Action Game<br>
<input type=radio value=\"d\" onClick=\"Engine(10, this.value)\">Simulation<p>

<center>
<input type=button onClick=\"NextLevel()\" value=\"Advance to next level\">
</center>
</form>

Og så her ved:
if (score >= 7 && score <= 11) {
        alert(\"Access permitted!  But there are no more levels if you don\'t make any ...\")
        //self.location=\"GameQuiz2.htm\"
Ville jeg gerne have den gik til en ny side i stedet for at der bare kommen en boks op!!!
Er der en der vil hjælpe mig?
Avatar billede Slettet bruger
28. august 2001 - 15:48 #1
Så fjerner du bare de to slash\'es:
if (score >= 7 && score <= 11) {
        alert(\"Access permitted!  But there are no more levels if you don\'t make any ...\")
        self.location=\"GameQuiz2.htm\"
}
Avatar billede Slettet bruger
28. august 2001 - 15:49 #2
Og hvis du vil have boksen fjernet, så:

if (score >= 7 && score <= 11) {
self.location=\"GameQuiz2.htm\"
}
Avatar billede kalkunen Nybegynder
28. august 2001 - 15:56 #3
Tak for hjælpen!!!!!
Avatar billede olebole Juniormester
28. august 2001 - 18:20 #4
<ole>
Tag også lige at skrive disse om:
  var ans = new Array;
  var done = new Array;
...til:
  var ans = new Array();
  var done = new Array();
...som er den rigtige syntaks.
/mvh
</bole>
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester