Untitled
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Law Explained - Online Test</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f9f9f9; } header { background-color: #004080; color: white; padding: 10px 20px; text-align: center; } main { padding: 20px; max-width: 800px; margin: 20px auto; background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); border-radius: 8px; } h1 { color: #004080; } .question { margin-bottom: 20px; } .question h3 { margin-bottom: 10px; } .options { margin-bottom: 15px; } button { background-color: #004080; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #003060; } </style> </head> <body> <header> <h1>Law Explained - Online Test</h1> </header> <main> <h2>Take Your Test</h2> <form id="testForm"> <div class="question"> <h3>1. What is the maximum tenure of a Chief Justice of India?</h3> <div class="options"> <label><input type="radio" name="q1" value="5 years"> 5 years</label><br> <label><input type="radio" name="q1" value="6 years"> 6 years</label><br> <label><input type="radio" name="q1" value="Until age of 65"> Until age of 65</label><br> <label><input type="radio" name="q1" value="Until age of 70"> Until age of 70</label> </div> </div> <div class="question"> <h3>2. Which Article of the Indian Constitution deals with "Equality Before Law"?</h3> <div class="options"> <label><input type="radio" name="q2" value="Article 12"> Article 12</label><br> <label><input type="radio" name="q2" value="Article 14"> Article 14</label><br> <label><input type="radio" name="q2" value="Article 16"> Article 16</label><br> <label><input type="radio" name="q2" value="Article 21"> Article 21</label> </div> </div> <button type="button" onclick="submitTest()">Submit</button> </form> <div id="result" style="margin-top: 20px; display: none;"> <h2>Your Score: <span id="score"></span>/2</h2> </div> </main> <script> function submitTest() { const answers = { q1: "Until age of 65", q2: "Article 14" }; let score = 0; const form = document.getElementById('testForm'); const result = document.getElementById('result'); const userAnswers = new FormData(form); for (let [key, value] of userAnswers.entries()) { if (answers[key] === value) { score++; } } document.getElementById('score').textContent = score; result.style.display = 'block'; } </script> </body> </html>
Leave a Comment