Skip to content

Commit 810fdae

Browse files
authored
Add files via upload
1 parent aeac7b5 commit 810fdae

File tree

4 files changed

+173
-0
lines changed

4 files changed

+173
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
8+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
9+
<script src="mathsopp.js"></script>
10+
</head>
11+
<body>
12+
13+
<div class="container">
14+
<div class="row justify-content-center">
15+
<div class="col-sm-6">
16+
17+
<div class="m-2">
18+
<label class="form-label">Number 1</label>
19+
<input type="text" id="num1" class="form-control">
20+
</div>
21+
<div class="m-2">
22+
<label class="form-label">Select One - </label>
23+
<select class="form-control" id="opp">
24+
<option>+</option>
25+
<option>*</option>
26+
<option>/</option>
27+
<option>-</option>
28+
</select>
29+
</div>
30+
<div class="m-2">
31+
<label class="form-label">Number 2</label>
32+
<input type="text" id="num2" class="form-control">
33+
</div>
34+
35+
36+
<button class="btn btn-primary m-3" onclick="checkopp()">Check Answer</button>
37+
38+
<div class="alert alert-success m-3" role="alert" id="printanswer">
39+
40+
</div>
41+
42+
</div>
43+
</div>
44+
</div>
45+
46+
47+
</body>
48+
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function checkopp(){
2+
3+
Number1 = document.getElementById("num1").value;
4+
Number2 = document.getElementById("num2").value;
5+
m_opp = document.getElementById("opp").value;
6+
7+
add = +Number1 + +Number2;
8+
mul = Number1*Number2;
9+
div = Number1/Number2;
10+
sub = Number1-Number2;
11+
12+
answer = document.getElementById("printanswer");
13+
14+
switch(m_opp){
15+
16+
case '+': answer.innerHTML = add;
17+
break;
18+
case '/': answer.innerHTML = div;
19+
break;
20+
case '*': answer.innerHTML = mul;
21+
break;
22+
case '-': answer.innerHTML = sub;
23+
break;
24+
25+
}
26+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
8+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
9+
<script src="mcq.js"></script>
10+
</head>
11+
<body>
12+
13+
<div class="container">
14+
<div class="row justify-content-center">
15+
<div class="col-sm-6">
16+
17+
<div class="alert alert-primary" role="alert">
18+
1 Which is best tutorial ?
19+
</div>
20+
<div class="alert alert-success" role="alert">
21+
<div class="form-check">
22+
<input type="radio" name="q1" value="1" class="form-check-input" id="a1">
23+
<label class="form-check-label" >
24+
a) www.codeswithpankaj.com
25+
</label>
26+
</div>
27+
<div>
28+
<div class="form-check">
29+
<input type="radio" name="q1" value="2" class="form-check-input" id="a2">
30+
<label class="form-check-label" >
31+
b) www.p4n.in
32+
</label>
33+
</div>
34+
<div>
35+
<div class="form-check">
36+
<input type="radio" name="q1" value="3" class="form-check-input" id="a3">
37+
<label class="form-check-label" >
38+
c) www.p4n.store
39+
</label>
40+
</div>
41+
<div>
42+
<div class="form-check">
43+
<input type="radio" name="q1" value="4" class="form-check-input" id="a4">
44+
<label class="form-check-label" >
45+
d) www.pn2.in
46+
</label>
47+
</div>
48+
<div>
49+
50+
</div>
51+
</div>
52+
53+
<button class="btn btn-primary m-3" onclick="checkAnswers()">Check Answer</button>
54+
55+
<div class="alert alert-success m-3" role="alert" id="printanswer">
56+
57+
</div>
58+
59+
</div>
60+
</div>
61+
</div>
62+
63+
64+
</body>
65+
</html>

Example/Switch Statement/mcq.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function checkAnswers() {
2+
// Get the selected answer
3+
let selectedAnswer = document.querySelector('input[name="q1"]:checked');
4+
5+
// Check if an answer is selected
6+
if (!selectedAnswer) {
7+
alert("Please select an answer.");
8+
return;
9+
}
10+
11+
12+
let answerValue = selectedAnswer.value;
13+
14+
15+
let print = document.getElementById('printanswer');
16+
17+
18+
switch(answerValue) {
19+
case "1":
20+
print.innerHTML = "Correct! www.codeswithpankaj.com";
21+
break;
22+
case "2":
23+
print.innerHTML = "Incorrect. Try again!";
24+
break;
25+
case "3":
26+
print.innerHTML = "Incorrect. Try again!";
27+
break;
28+
case "4":
29+
print.innerHTML = "Incorrect. Try again!";
30+
break;
31+
default:
32+
print.innerHTML = "An error occurred. Please try again.";
33+
}
34+
}

0 commit comments

Comments
 (0)