Jump to content
Sign in to follow this  
Guest Tigerback

Quiz script

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

Share this post


Link to post
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. :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...