Basic Quiz Task in JS

Basic Quiz Task in JS

<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
	<title> JS QUIZ</title>
	<script>
	function validation()
        {
	var Q1=document.Quiz.Q1;
	var Q2=document.Quiz.Q2;
	var Q3=document.Quiz.Q3;
	var Q4=document.Quiz.Q4;
	var Q5=document.Quiz.Q5;
	var sum=0;
	if(Q1.value==11)
	{
		sum=10+sum;
	}
	if(Q2.value==15)
	{
		sum=10+sum;
	}
	if(Q3.value==20)
	{
		sum=10+sum;
	}
document.write("Your Number is"+sum+"<hr>");
return true;
}
</script>
</head>
<body>
	<div class="container">
		<div class="row m-auto" >
			<h1 class="text-center text-success">JS QUIZ</h1>
			<div class="col-12">
				<form name="Quiz" action="" onsubmit="return validation();" method="post">
	<div class="form-group mt-3" >
		<label for="gender">What is the total of 6+5:</label>
	</div>
	<div class="form-check">
		<input type="radio" name="Q1" value="11" class="form-check-input">
		<label for="male">11</label>
	</div>
	<div class="form-check">
		<input type="radio" name="Q1" value="12" class="form-check-input" >
		<label for="gender">12</label>
	</div>
	<div class="form-check">
		<input type="radio" name="Q1" value="15" class="form-check-input" >
		<label for="gender">15</label>
	</div>

	<div class="form-group mt-3" >
		<label for="gender">What is the total of 7+8:</label>
	</div>
	<div class="form-check">
		<input type="radio" name="Q2" value="15" class="form-check-input">
		<label for="male">15</label>
	</div>
	<div class="form-check">
		<input type="radio" name="Q2" value="12" class="form-check-input" >
		<label for="gender">12</label>
	</div>
	<div class="form-check">
		<input type="radio" name="Q2" value="40" class="form-check-input" >
		<label for="gender">40</label>
	</div>
					
	<div class="form-group mt-3" >
		<label for="gender">What is the total of 10+10:</label>
	</div>
	<div class="form-check">
		<input type="radio" name="Q3" value="20" class="form-check-input">
		<label for="male">20</label>
	</div>
	<div class="form-check">
		<input type="radio" name="Q3" value="10" class="form-check-input" >
		<label for="gender">10</label>
	</div>
	<div class="form-check">
		<input type="radio" name="Q3" value="15" class="form-check-input" >
		<label for="gender">15</label>
	</div>
			
	<div class="form-group text-center mt-3" >
		<button type="submit" class="btn btn-success btn-lg px-5 border-0 rounded-0 " value="SUBMIT" >SUBMIT RESOPNSE</button>
	</div>
</form>
</div></div></div>
</body>
</html>
One thought on “Basic Quiz Task in JS

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*