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+
8+ < script >
9+
10+ function q1 ( ) {
11+ answer = document . getElementById ( "select_option" ) . value ;
12+
13+ right_answer = "mars" ;
14+ print = document . getElementById ( "q1_answer" ) ;
15+ if ( answer == right_answer ) {
16+ print . innerHTML = "Right Answer = " + answer ;
17+ } else {
18+ print . innerHTML = "wrong Answer = " + answer ;
19+ }
20+
21+ }
22+
23+
24+ function q2 ( ) {
25+ const selectedanswer = document . querySelector ( 'input[name="option"]:checked' ) ;
26+ right_answer = "ajinkya" ;
27+ print = document . getElementById ( "q2_answer" ) ;
28+ if ( selectedanswer . value == right_answer ) {
29+ print . innerHTML = "Right Answer = " + selectedanswer . value ;
30+ } else {
31+ print . innerHTML = "wrong Answer = " + selectedanswer . value ;
32+ }
33+
34+ }
35+
36+ </ script >
37+
38+
39+ </ head >
40+ < body >
41+
42+ < h1 > MCQ Exam</ h1 >
43+
44+ < p >
45+ 1 Which planet is known as the Red Planet ?
46+ </ p >
47+ < select id ="select_option ">
48+ < option value ="jupiter "> Jupiter</ option >
49+ < option value ="mars "> Mars</ option >
50+ < option value ="venus "> Venus</ option >
51+ < option value ="saturn "> Saturn</ option >
52+ </ select >
53+ < br >
54+ < br >
55+ < button onclick ="q1() "> Result</ button >
56+ < p id ="q1_answer "> </ p >
57+
58+ < p >
59+ 2 Who was the first Prime Minister of India? ?
60+ </ p >
61+ < input type ="radio " name ="option " value ="bhoomi "> Bhoomi < br >
62+ < input type ="radio " name ="option " value ="sumit "> Sumit < br >
63+ < input type ="radio " name ="option " value ="ajinkya "> ajinkya < br >
64+ < input type ="radio " name ="option " value ="pankaj "> Pankaj < br >
65+ < br >
66+ < br >
67+ < button onclick ="q2() "> Result</ button >
68+ < p id ="q2_answer "> </ p >
69+
70+
71+ </ body >
72+ </ html >
0 commit comments