Simple Quiz
How do I make an simple quiz?
What is a simple quiz? How do you make a simple quiz? This script and codes were developed by Lisa Macken on 01 October 2022, Saturday.
Simple Quiz - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple Quiz</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <html> <head> <title>Simple JavaScript Quiz</title> <link rel="stylesheet" href="css/style.css"> <script src="js/script.js"></script> </head> <body> <div id="container"> <header> <h1>Simple JavaScript Quiz</h1> <p>Test your knowledge in <strong>JavaScript fundamentals</strong></p> </header> <section> <div id="results"></div> <form name="quizForm" onsubmit="return submitAnswers()"> <h3>1. In which HTML element do we put in JavaScript code?</h3> <input type="radio" name="q1" value="a" id="q1a">a. <js><br> <input type="radio" name="q1" value="b" id="q1b">b. <script><br> <input type="radio" name="q1" value="c" id="q1c">c. <body><br> <input type="radio" name="q1" value="d" id="q1d">d. <link><br> <h3>2. Which HTML attribute is used to reference an external JavaScript file?</h3> <input type="radio" name="q2" value="a" id="q2a">a. src<br> <input type="radio" name="q2" value="b" id="q2b">b. rel<br> <input type="radio" name="q2" value="c" id="q2c">c. type<br> <input type="radio" name="q2" value="d" id="q2d">d. href<br> <h3>3. How would you write "Hello" in an alert box?</h3> <input type="radio" name="q3" value="a" id="q3a">a. msg("Hello");<br> <input type="radio" name="q3" value="b" id="q3b">b. alertBox("Hello");<br> <input type="radio" name="q3" value="c" id="q3c">c. document.write("Hello");<br> <input type="radio" name="q3" value="d" id="q3d">d. alert("Hello");<br> <h3>4. JavaScript is directly related to the "Java" programming language</h3> <input type="radio" name="q4" value="a" id="q4a">a. True<br> <input type="radio" name="q4" value="b" id="q4b">b. False<br> <h3>5. A variable in JavaScript must start with which special character</h3> <input type="radio" name="q5" value="a" id="q5a">a. @<br> <input type="radio" name="q5" value="b" id="q5b">b. $<br> <input type="radio" name="q5" value="c" id="q5c">c. #<br> <input type="radio" name="q5" value="d" id="q5d">d. No Special Character<br> <br><br> <input type="submit" value="Submit Answers"> </form> </section> <footer> <p>Copyright © 2017, All Rights Reserved</p> </footer> </div> </body>
</html> <script src="js/index.js"></script>
</body>
</html>
Simple Quiz - Script Codes CSS Codes
body { background: #f06226; color: #fff; font-family: "arial", sans-serif; font-size: 14px;
}
#container { width: 60%; background: #199fdb; margin: 20px auto; overflow: auto; padding: 25px;
}
header { text-align: center; border-bottom: #fff dashed 1px;
}
header h1 { margin: 0; padding: 0;
}
header p { padding: 0; margin-top: 5px; color: #000;
}
section { min-height: 400px;
}
footer { text-align: center;
}
input[type="submit"]{ background: #f06226; border: 0; color: #fff; padding: 10px 15px; cursor: pointer;
}
#results h3 { background: #f06226; padding: 10px; margin: 10px 0;
}
#results span { color: #000; font-weight: bold;
}
Simple Quiz - Script Codes JS Codes
function submitAnswers(){ var total = 5; var score = 0; // Get user Input var q1 = document.forms["quizForm"]["q1"].value; var q2 = document.forms["quizForm"]["q2"].value; var q3 = document.forms["quizForm"]["q3"].value; var q4 = document.forms["quizForm"]["q4"].value; var q5 = document.forms["quizForm"]["q5"].value; // Validation for (i = 1; i <= total; i++){ if (eval('q'+i) == null || eval('q'+i) == ''){ alert('You missed question ' + i); return false; } } // Set correct Answers var answers = ["b","a","d","b","d"]; // check the answers for (i = 1; i <= total; i++){ if(eval('q'+i) == answers[i - 1]){ score++; } } // Display Results var results = document.getElementById('results'); results.innerHTML = '<h3>You scored <span>'+score+'</span> out of <span>'+total+' !</span></h3>'; alert('You scored '+ score+ 'out of '+ totol); return false;
}
Developer | Lisa Macken |
Username | lmack90 |
Uploaded | October 01, 2022 |
Rating | 3 |
Size | 2,847 Kb |
Views | 30,360 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
A Pen by Lisa Macken | 2,231 Kb |
SVG icons | 3,809 Kb |
Rollover Effect 1 | 2,582 Kb |
Columns everywhere | 1,761 Kb |
Animation examples | 1,850 Kb |
A JQuery Mobile Quiz Game | 4,406 Kb |
Menu smoothscroll | 3,874 Kb |
Image moves with mouse | 1,974 Kb |
Scrollable svg Animations | 2,980 Kb |
Carousel | 2,620 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
CSS3 Media Queries demo | Machal | 1,824 Kb |
Wikipedia Viewer | Thalpha | 4,426 Kb |
Full page table inside the grid | Twikito | 1,864 Kb |
Off Canvas | Mariamarica | 1,870 Kb |
Canvas Orbital Trails v2 | Jackrugile | 3,421 Kb |
Get third wednesday | Wojtek1150 | 2,691 Kb |
Codero Sitemap | S1m0ne | 28,169 Kb |
Scifi-style Interative Form | Aaronchuo | 4,566 Kb |
Transitioning application screens with semantically named classes | Djgrant | 3,697 Kb |
Zeichensatz | Moklick | 2,058 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!