Friday, January 25, 2013

Online QUIZ using Javascript


<!--ONLINE QUIZ example ......fensasaj@blogspot.com.-->
<HEAD>
     
    <SCRIPT LANGUAGE="JavaScript">
   
     
    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";
 
    function Pop(question, answer) {
    if (answer != ans[question]) {
    if (!done[question]) {
    done[question] = -1;
    alert("Wrong! and Your score is now: " + score);
    }
    else {
    alert("You have already answered that!");
       }
    }
    else {
    if (!done[question]) {
    done[question] = -1;
    score++;
    alert("Correct!and Your score is now: " + score);
    }
    else {      
    alert("You have already answered that!");
          }
       }
    }
         
    function NextLevel () {
    if (score > 5) {
    alert("Cheater!");
    }
    if (score >= 3 && score <= 6) {
    alert("Access permitted!  But there are no more levels if you don't make any ...")
     
    //change previous line to: self.location="js_misc_userquiz2.html" if you make more
     
    }
    else {
    alert("Access denied!  You need 3 points to enter the next level.")
       }
    }
   
    </SCRIPT>
     
 
     
    <BODY>
     
    <font size=7 face=Arial>Online Quiz</font><br><p>
    <b>Objective: answer 3 questions correctly.  JavaScript required!</b><p>
    <noscript>JavaScript is <b><i>disabled</b></i>.  Get Netscape 3.0 or turn it on!</noscript>
    <hr noshade>
    <FORM>
    <b>1. Which is the capital of  <i>Canada</i>?</b><p>
    <input type=radio value="a" onClick="Pop(1, this.value)">Doha<br>
    <input type=radio value="b" onClick="Pop(1, this.value)">Canbera<br>
    <input type=radio value="c" onClick="Pop(1, this.value)">Ottawa<br>
    <input type=radio value="d" onClick="Pop(1, this.value)">Vienna<p>
    <b>2. Where is the head quarters of <i>UNESCO</i>?</b><p>
    <input type=radio value="a" onClick="Pop(2, this.value)">Paris<br>
    <input type=radio value="b" onClick="Pop(2, this.value)">Switzerland<br>
    <input type=radio value="c" onClick="Pop(2, this.value)">Brazil<br>
    <input type=radio value="d" onClick="Pop(2, this.value)">Delhi<p>
    <b>3. Which is the first country to introduce currency notes ?</b><p>
    <input type=radio value="a" onClick="Pop(3, this.value)">India<br>
    <input type=radio value="b" onClick="Pop(3, this.value)">China<br>
    <input type=radio value="c" onClick="Pop(3, this.value)">Pakisthan<br>
    <input type=radio value="d" onClick="Pop(3, this.value)">Sri Lanka<p>
    <b>4. Who is the first Indian Nobel Laurette?</b><p>
    <input type=radio value="a" onClick="Pop(4, this.value)">Amartya Sen<br>
    <input type=radio value="b" onClick="Pop(4, this.value)">Rabindra Nath Tagore<br>
    <input type=radio value="c" onClick="Pop(4, this.value)">Indira Gandhi<br>
    <input type=radio value="d" onClick="Pop(4, this.value)">Mother Theresa<p>
    <b>5. Who invented Radio? </b><p>
    <input type=radio value="a" onClick="Pop(5, this.value)">Edison<br>
    <input type=radio value="b" onClick="Pop(5, this.value)">Bell<br>
    <input type=radio value="c" onClick="Pop(5, this.value)">Newton<br>
    <input type=radio value="d" onClick="Pop(5, this.value)">Marcony<p>
   
    <CENTER>
    <input type=button onClick="NextLevel()" value="Advance to next level">
    </CENTER>
    </FORM>                


No comments:

Post a Comment