Javascript Quiz
How do I make an javascript quiz?
What is a javascript quiz? How do you make a javascript quiz? This script and codes were developed by Joe Warren on 22 October 2022, Saturday.
Javascript Quiz - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Javascript Quiz</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <html lang="en">
<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" href="../../favicon.ico"> <title>JavaScript Quiz</title> <link rel="stylesheet" type="text/css" href="styles.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body> <div class="container"> <div class="header clearfix"> <h3 class="text-muted">Code Jobber</h3> </div> <div class="jumbotron"> <h1>Javascript Quiz</h1> <p class="lead">Test your Javascript knowledge with this 5 question quiz. You have no time limit, and you will receive your score upon completing the quiz. Good luck!</p> <!-- <p><a class="btn btn-lg btn-success" href="#" role="button">Start</a></p> --> </div> <!-- create form that contains questions --> <section> <div id="results"></div> <form name="quizForm" onsubmit="return submitAnswers()"> <label>1. In which HTML elements do we put in JavaScript code?</label> <br> <!-- answer: b. script --> <input class="radioJ" type="radio" name="q1" value="a"> a. <js><br> <input class="radioJ" type="radio" name="q1" value="b"> b. <script><br> <input class="radioJ" type="radio" name="q1" value="c"> c. <body><br> <input class="radioJ" type="radio" name="q1" value="d"> d. <head><br><br> <label>2. Which HTML attribute is used to reference an external Javascript file?</label> <br> <!-- answer: a. src --> <input type="radio" name="q2" value="a"> a. <src><br> <input type="radio" name="q2" value="b"> b. <p><br> <input type="radio" name="q2" value="c"> c. <footer><br> <input type="radio" name="q2" value="d"> d. <Java><br><br> <label>3. How do we call an alert box?</label> <br> <!-- answer: d. alert("Hello") --> <input type="radio" name="q3" value="a"> a. alert.box<br> <input type="radio" name="q3" value="b"> b. call<br> <input type="radio" name="q3" value="c"> c. Flintstone("Hello");<br> <input type="radio" name="q3" value="d"> d. alert("Hello");<br><br> <label>4. JavaScript is the same as Java?</label> <br> <!-- answer: a. False --> <input type="radio" name="q4" value="a"> a. False<br> <input type="radio" name="q4" value="b"> b. True<br><br> <label>5. How do you comment a line out in JavaScript?</label> <br> <!-- answer: c. // --> <input type="radio" name="q5" value="a"> a. %<br> <input type="radio" name="q5" value="b"> b. +<br> <input type="radio" name="q5" value="c"> c. //<br> <input type="radio" name="q5" value="d"> d. Cena<br><br> <input type="Submit" name="Submit Answers" class="btn btn-lg btn-success" id="submitJones"> </form> </section> <footer class="footer"> <p>© 2017 | Code Jobber</p> </footer> </div> <!-- container --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script type="text/javascript" src="script.js"></script> </body> </html> <script src="js/index.js"></script>
</body>
</html>
Javascript Quiz - Script Codes CSS Codes
/* Space out content a bit */
body { padding-top: 20px; padding-bottom: 20px;
}
/* Everything but the jumbotron gets side spacing for mobile first views */
.header,
.marketing,
.footer { padding-right: 15px; padding-left: 15px;
}
/* Custom page header */
.header { padding-bottom: 20px; border-bottom: 1px solid #e5e5e5;
}
/* Make the masthead heading the same height as the navigation */
.header h3 { margin-top: 0; margin-bottom: 0; line-height: 40px;
}
/* Custom page footer */
.footer { padding-top: 19px; color: #777; border-top: 1px solid #e5e5e5;
}
/* Customize container */
@media (min-width: 768px) { .container { max-width: 730px; }
}
.container-narrow > hr { margin: 30px 0;
}
/* Main marketing message and sign up button */
.jumbotron { text-align: center; border-bottom: 1px solid #e5e5e5;
}
.jumbotron .btn { padding: 14px 24px; font-size: 21px;
}
/* Supporting marketing content */
.marketing { margin: 40px 0;
}
.marketing p + h4 { margin-top: 28px;
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) { /* Remove the padding we set earlier */ .header, .marketing, .footer { padding-right: 0; padding-left: 0; } /* Space out the masthead */ .header { margin-bottom: 30px; } /* Remove the bottom border on the jumbotron for visual effect */ .jumbotron { border-bottom: 0; }
}
#submitJones { margin-bottom: 20px;
}
Javascript 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 //Looping through the question for (var i = 1; i <= total; i++) { //If we miss one, we output an alert box if(eval('q' + i) == null || eval('q' + i) == ''){ alert('You missed question ' + i); return false; } } //Set Correct Answers var answers = ['b', 'a', 'd', 'a', 'c']; //Check 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 <strong>' + score + '</strong> out of <strong>' + total + '</strong> </h3>'; alert('You scored ' + score + ' out of ' + total); return false;
}
Developer | Joe Warren |
Username | MightyJoeW |
Uploaded | October 22, 2022 |
Rating | 3 |
Size | 3,596 Kb |
Views | 28,336 |
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 |
MLK Google Homepage project | 3,048 Kb |
First Gen Pokemon Chart | 8,639 Kb |
Navbar test | 3,249 Kb |
React basic lesson | 2,378 Kb |
2017-04-02 Weather App | 1,708 Kb |
Bouncing Basketball | 1,614 Kb |
Joe Warren Portfolio Deluxe | 13,097 Kb |
Weather App 2 | 2,877 Kb |
Joe Warren Portfolio | 7,339 Kb |
HEEL Rock Paper Scissors | 5,433 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 |
Tail rose iris lined | Kbrtrm | 1,846 Kb |
Spin | Elalemanyo | 8,262 Kb |
Rrremark.com Overlay Highlighter | Derickruiz | 4,438 Kb |
V.35 The Monolith Update - Hero Release Notes | Jordan | 12,045 Kb |
Email Marketing Mock | Kristenzirkler | 8,224 Kb |
Tree growth tests | Orchard | 3,818 Kb |
Box Shadow Effects | Retrofuturistic | 2,143 Kb |
CSS3 Selectables with information rollover | Jasonmayes | 9,565 Kb |
PNotify Demo | Adittmar | 1,731 Kb |
Donald Trump - The New Yorker | Agbales | 2,502 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!