Jump to content

Quiz script


Guest Tigerback
 Share

Recommended Posts

Guest Tigerback

This is my first look at using javascript so i am completely green.i want to make a quiz , 10 questions , 1 on each page with an 11th page displaying the resultsWhats the easiest way to achieve this? In my head it seemed easy , just carry a 1 forward for a correct answer and a 0 for wrong with it having a running total throughout. But when i have looked at how to do it , i can't find help or a templete . Any help will be appreciated

Link to comment
Share on other sites

Well this is a nice problem. Let me present the solution with a small code which can be modified for your problem easily...Here we will transfer three values from one html file ( a.html ) to a second html file ( b.html ) a.html ----------------------3 Values------------------------> b.html*************** Code for a.html *****************<html> <head> <title>a</title> <script> function callB(value1,value2,value3) { var parasite=escape(value1)+","+escape(value2)+","+escape(value3); window.location="b.html?"+parasite; } </script> </head> <body> <h1><b>This Is a.html<b></h1><br><br> Passing These Values To b.html<br> value1="W";<br>value2=3;<br>value3="Schools Online";<br> <a href="java script:callB('W',3,'Schools Online');">Click Here To Pass Values To b.html</a> </body></html>*************** Code for b.html *****************<html> <head> <title>this is b.html</title> </head> <body> <h1><b>This Is b.html<b></h1><br><br><br> Values Passed from a.html are.....<br><br> <script> var parasite=window.location.search; parasite=parasite.substring(1); //removing the ? character //converting the string into array elements. var arrayParasite=parasite.split(','); //unescaping and displaying the result for (i=0;i<arrayParasite.length;i++) { arrayParasite=unescape(arrayParasite); document.write("Value " + (i+1) +" : " +arrayParasite+"<br>"); } </script> </body></html>But of course this is not the best way to do it. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...