JavaScript Quiz App Source Code

How To Make a Quiz App With JavaScript Using Visual Studio Code

JavaScript Quiz App Source Code


In this JavaScript Tutorial we will see How to Make a Simple Quiz App Using a Paragraph, RadioButtons and a Button In JavaScript and Visual Studio Code .



Project Source Code:


<!DOCTYPE HTML>

<head>
<style>
#q-div{background-color: lightgray; border: 1px solid darkgray; width:25%;
padding: 25px; margin-bottom: 35px;}

input{margin-bottom: 14px}
button{background-color: black; color: yellow}

</style>
</head>

<body>

<div id="container">
<div id="content">
<div id="q-div">
<p id="q-content"> Question Here ?</p>
</div>
<input onclick="getSelectedRbutton(this)" type="radio" name="ops"
class="rb" id="op1" value="A">
<label class="lbl" for="op1">Option 1</label><br>

<input onclick="getSelectedRbutton(this)" type="radio" name="ops"
class="rb" id="op2" value="B">
<label class="lbl" for="op2">Option 2</label><br>

<input onclick="getSelectedRbutton(this)" type="radio" name="ops"
class="rb" id="op3" value="C">
<label class="lbl" for="op3">Option 3</label><br>

<input onclick="getSelectedRbutton(this)" type="radio" name="ops"
class="rb" id="op4" value="D">
<label class="lbl" for="op4">Option 4</label><br><br>

<button onclick="play()" id="btn">Next Question</button>

</div>

</div>


<script>
const questions = ["15 + 15 = ?","100 / 10 = ?","200 X 4 = ?",
"250 - 150 = ?","27 / 9 = ?"]
// the last item in the options list row is the correct answer
/* the four other are the options we gonna show the user and
one of them is the correct one */
const options = [["1","30","3","4","30"],["10","30","25","1000","10"],
["100","30","8000","800","800"],["100","300","500","450","100"],
["10","5","3","4","3"]]
// get the radio buttons
rbuttons = document.getElementsByName("ops");
// get the labels
lbls = document.getElementsByClassName("lbl");
// index to go through the questions
// correct to count the correct answers
index = 0, correct = 0;
q_div = document.getElementById("q-div");
question = document.getElementById("q-content");
btn = document.getElementById("btn");


// create a unction to get the selected radio button value
function getSelectedRbutton(rbtn)
{

console.log(rbtn.value);
// check if the user has selected the correct answer
if(rbtn.value == options[index][4]){
correct++;
}
index++;
rButtonsState("d");

}

// create a function to enable and disable radio buttons
function rButtonsState(st)
{
if(st == "d") // d for disable
{
rbuttons.forEach(element => {
element.disabled = true;
});
}
else
{// enable
rbuttons.forEach(element => {
element.disabled = false;
});
}
}
// create the main function to play
function play()
{
// display the question
question.innerHTML = questions[index];
// get the options
op = options[index];
if(btn.innerHTML == "Restart")
{
q_div.style.backgroundColor = "lightgray";
q_div.style.borderColor = "darkgray";
btn.innerHTML = "Next";
}

if(index == questions.length)
{
// if half or more of the answers are correct
if(correct >= questions.length/2)
{
q_div.style.backgroundColor = "lightgreen";
q_div.style.borderColor = "green";
question.innerHTML = correct + " Answers Are Correct";
}
else{
q_div.style.backgroundColor = "lightcoral";
q_div.style.borderColor = "red";
question.innerHTML = correct + " Answers Are Correct";
}

btn.innerHTML = "Restart";
index = 0;
correct = 0;

}
else
{
// enable radiobuttons
rButtonsState("e");
// display the options in labels and radiobuttons
for(var i = 0; i < lbls.length; i++)
{
rbuttons[i].value = op[i];
lbls[i].innerHTML = op[i];
rbuttons[i].checked = false;
}
// if it's the last question
if(index == questions.length - 1 )
{
btn.innerHTML = "Finish and See the Result";
}
}
}
play();

</script>

</body>

</html>                                              



////// OUTPUT : 











download the source code






Asp.Net Projects Source Code

 9 ASP.NET Web Projects With Source Code

Asp.Net Projects Source Code

if you already know C# and you want to start creating web apps, then ASP.NET is the way to go.
ASP.NET is a framework that allow you to build web apps and services.

and in this post i'm gonna share with you a list of Asp.net projects, so you can have a better understinding and view of real world asp.net projects.


1) ASP.NET POS - Point of Sale


"C# based web applications that help you to manage your stock. Update stock item, purchase/add item and sales from anywhere around the globe  Office, Home, shop, PC or Mobile. You only need internet connection for it."









2) ASP.NET CORE with EF Core - Invoice Generator 


"In this Invoice Generator System, you can easily setup your Company, manage Customer, manage Products, manage Sales and generate your own company Invoice easily. you can access Invoice system with Mobile, fully responsive experience!."









3) ASPNET - Drag N' Drop Form-builder


"Create any form you want using drag-and-drop functionality. Store registrants in a database and export to excel as desired."













4) ASP.NET Core - CRM and Inventory Web App  (MVC)


"Perfect for those who wants to learn Microsoft latest modern technology stack, ASP.NET Core MVC combine with Bootstrap, jQuery and selected plugin such as chart."








5) ASP.NET - Pharmacy management System (MVC)


"Pharmacy Management System for Small and medium business who wants to track their shop with stock, purchases, sales and generate sales report, purchase report and so many things."











6) ASP.NET HRM - Human Resource Management ASP.NET CORE EF CORE


"Cute Slider is a unique and easy to use slider with awesome 3D and 2D transition effects, captions, 4 ready to use templates, and more impressive features which written with pure object oriented javascript."











7) ASP.NET MVC - Online Examination System


"This is an online exam system which enables multiple admins to create teacher and student users, subjects, classes, and so on. The teacher can log in to create exams, set an exam start time, and set open to which class, and much more."










8) ASP.NET MVC - Learning Management System


"This E-Learning ASP.NET MVC5 Web Application aims to help the school, university, tuition centre, private organization to perform online learning which let the teachers/instructors and students to perform some common class activities online."









9) ASP.NET - Online Grocery Shop




"Ecommerce Multi vendor responsive marketplace developed using Asp dot net, SQL server, Bootstrap.."















JavaScript Projects Source Code

Download JavaScript Projects and Scripts

JavaScript Projects Source Code

Are you Loking for JavaScript Projects to Download?

JavaScript is one of the must know programming language if you want to become a web developper.

if you want to learn JavaScript so you can start building your own projects then check this premium course >>check this javascript course<< .

now let's see the projects list!

1) JavaScript Slider - 3D & 2D HTML5 Image Slider

JavaScript Project 1 Source Code

"Cute Slider is a unique and easy to use slider with awesome 3D and 2D transition effects, captions, 4 ready to use templates, and more impressive features which written with pure object oriented javascript."






2) JavaScript Builder - HTML Email & Page Builder

JavaScript Projects 2 Source Code

"BuilderJS is a JavaScript plugin which provides a web user interface for building / editing HTML emails or web pages."







3) JavaScript Game - Creepy Flappy

JavaScript Projects 3 Source Code

"The Creepy Flappy is an HTML5 (pure javascript) game where a strange bird must fly without hitting the blocks. Try to get as far as possible. Enjoy atmospheric sounds and graphics."










4) JavaScript Search – Hotels Search Form

JavaScript Projects 4 Source Code

"Ocean Star is a JavaScript library for customizable and intuitive hotel search forms with plenty of different features and options. It has a responsive country autocomplete, powerful date range picker with a modern calendar widget, and guest selector with the possibility to add fields dynamically. It makes it easy to add a great-looking hotel search forms to your website or application."









5) JavaScript NAVX - Ultimate Navigation Plugin

JavaScript Projects 5 Source Code

"NAVX does not use jQuery or other library to work. It’s fast!,Ready to use on mobile phones, tablets and desktop devices."








6) Fab Buttons, Message Box, Cookie Law Alert and Contact Form

JavaScript Projects 6 Source Code

"A simple pure Javascript plugin. For corner sweet buttons, cookie law alerts, working contact forms, message boxes and much more."









7) jQuery Countdown

JavaScript Projects 7 Source Code

"jCountdown is a jQuery plugin, you can easily to use it on your site."






8) Image Cropper, Responsive Uploading and Ratio Cropping Plugin

JavaScript Projects 8 Source Code

"Crop images with Slim, a cross platform Image Cropping and Uploading plugin. It’s very easy to setup and features beautiful graphics and animations."







9) Smart Forms

JavaScript Projects 9 Source Code

"Smart Forms is a responsive professional Form Framework with a clean consistent Form UI. The framework includes a variety of form Widgets such as Datepickers, Timepickers, Monthpickers, Colorpickers, Numeric Steppers, UI Sliders, Google maps, toggle switches validation, masking among other features."









10) Upload Image, Ratio with Drag and Drop

JavaScript Projects 10 Source Code

"an HTML5 Upload image tool, full use of HTML5 with canvas (with fallback options). Together with a ratio and drag & drop."






11) Media Boxes Portfolio - jQuery Grid Gallery Plugin

JavaScript Projects 11 Source Code

"Media Boxes Portfolio is a featured jQuery grid plugin that allows you to display all kind of content in a highly powerful grid. Use it for blog posts, display media, clients, portfolios, shopping carts, galleries and all you can imagine."









12) jQuery Banner Rotator / Slideshow

JavaScript Projects 12 Source Code

"This is a jQuery banner rotator plugin featuring multiple transitions. The thumbnails and buttons allow for easy navigation of your banners/ads. The banner rotator is also re-sizable and configurable through the plugin’s parameters."