html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Behaviour Quiz</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
</head>
<body>
<div class="quiz-container">
<div class="quiz-header">
<h1>Discover Your Personality</h1>
<p>Answer these questions to reveal your true nature</p>
<div id="progress-bar"><div id="progress"></div></div>
</div>
<form id="quiz-form">
<!-- Emoji-Based Questions ❓ -->
<div class="question" id="q1">
<p class="question-text">1. How do you recharge?</p>
<div class="options">
<label class="option">
<input type="radio" name="q1" value="social">
<span class="emoji">🥳</span>
<span class="option-text">Being around people</span>
</label>
<label class="option">
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
body {
font-family: Arial, sans-serif;
background: #222;
color: white;
text-align: center;
padding: 20px;
}
.quiz-container {
background: #333;
padding: 20px;
border-radius: 10px;
width: 90%;
max-width: 500px;
margin: auto;
}
.question {
margin-bottom: 20px;
padding: 15px;
background: #444;
border-radius: 8px;
transition: all 0.3s;
}
input[type="radio"] {
margin-right: 10px;
}
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
window.onload = function() {
const form = document.getElementById('quiz-form');
const progress = document.getElementById('progress');
const resultDiv = document.getElementById('result');
const personalityText = document.getElementById('personality-text');
const personalityImage = document.getElementById('personality-image');
let progressValue = 0;
// Update progress when answering each question
form.addEventListener('change', function() {
progressValue += 100 / 9;
progress.style.width = `${progressValue}%`;
});
// Submit function
form.addEventListener('submit', function(event) {
event.preventDefault();
if (!validateQuiz()) {
alert("Please answer all questions before submitting!");
return;
}
setTimeout(() => {
const answers = new FormData(form);
let personality = calculatePersonality(answers);
BROWSER
Console
Uruchom