Trivia Type Thing
2 posters
Page 1 of 1
Trivia Type Thing
Is there a way to create , like a test sorta, where you can insert this test into a HTML page, and after the member is done with the test, have a test result after?
Example:
Spyro is a ?
A- Fly
B- Dragon
C- LIzzard
** Chooses A ***
** goes to next question **
Sparx is a ?
A Dragon
B Dragonfly
C Lizzard
D Fairy
*** Chooses B ***
*** Loading Test Results ***
*** You got 1 out of 2 questions correct ***
Example:
Spyro is a ?
A- Fly
B- Dragon
C- LIzzard
** Chooses A ***
** goes to next question **
Sparx is a ?
A Dragon
B Dragonfly
C Lizzard
D Fairy
*** Chooses B ***
*** Loading Test Results ***
*** You got 1 out of 2 questions correct ***
Re: Trivia Type Thing
You can add this in an html page:
Code from w3schools, modified to fit your needs.
If you need more questions, you can add them here and i can modify the HTML for you if you would like, or have trouble doing so.
- Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>title</title>
<style>
.rightans{
border:3px solid #0f0;
background-color: #afa;
}
.wrongans{
border:3px solid #f00;
background-color: #faa;
}
</style>
<script>
window.onerror = function(m, u, l){
alert('Javascript Error: '+m+'\nURL: '+u+'\nLine Number: '+l);
return true;
}
</script>
<script>
'use strict';
window.onload = init;
function init() {
document.getElementById('btn').onclick = validate;
document.getElementById('btnclr').onclick = clear;
}
function validate() {
var radios = document.getElementById("quiz").getElementsByTagName("INPUT");
var right = 0;
var wrong = 0;
for(var i=0, len=radios.length ; i<len ; i++) {
if(radios[i].value == "x") {
if(radios[i].checked == true){
right++;
radios[i].parentNode.parentNode.className = 'rightans';
}else{
wrong++;
radios[i].parentNode.parentNode.className = 'wrongans';
}
}
}
var pcnt = (100*right/(wrong+right)).toFixed(1);
document.getElementById("score").innerHTML = 'Correct: '+ right +'<br/>Incorrect: ' + wrong +'<br/>Percent Correct: ' + pcnt +'%';
}
function clear(){
var radios = document.getElementById("quiz").getElementsByTagName("INPUT");
for(var i=0, len=radios.length ; i<len ; i++) {
radios[i].checked = false;
if (radios[i].value == "x"){
radios[i].parentNode.parentNode.className = '';
}
}
document.getElementById("score").innerHTML = '';
}
</script>
</head>
</body>
<div id="quiz">
<h1>Quiz</h1>
<fieldset id="q1">
<legend>Question 1</legend>
<legend>Spyro is a ___</legend>
<label><input type="radio" name="q1" value="p"/>Fly</label><br/>
<label><input type="radio" name="q1" value="x"/>Dragon</label><br/>
<label><input type="radio" name="q1" value="y"/>Lizzard</label><br/>
</fieldset>
<fieldset id="q2">
<legend>Question 2</legend>
<legend>Sparx is a __</legend>
<label><input type="radio" name="q2" value="s"/>Fairy</label><br/>
<label><input type="radio" name="q2" value="l"/>Dragon</label><br/>
<label><input type="radio" name="q2" value="x"/>Dragonfly</label><br/>
<label><input type="radio" name="q2" value="r"/>Lizzard</label>
</fieldset>
</div>
<input type="button" id="btn" value="Check Answers"/>
<input type="button" id="btnclr" value="Clear"/>
<h2 id="score"></h2>
</body>
</html>
Code from w3schools, modified to fit your needs.
If you need more questions, you can add them here and i can modify the HTML for you if you would like, or have trouble doing so.
Similar topics
» New "announcement" type thing
» Gretting Type Thing! Help Me!!!
» Sorting Hat Type Thing
» Chatbox Notification type thing?
» Trivia
» Gretting Type Thing! Help Me!!!
» Sorting Hat Type Thing
» Chatbox Notification type thing?
» Trivia
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum