-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTRUTHQUESTION.HTML
More file actions
141 lines (124 loc) · 4.47 KB
/
Copy pathTRUTHQUESTION.HTML
File metadata and controls
141 lines (124 loc) · 4.47 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Truth Survey</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
.survey-container {
max-width: 600px;
margin: 0 auto;
background-color: #f9f9f9;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
font-size: 24px;
}
.question {
margin-bottom: 20px;
}
.question label {
font-size: 18px;
display: block;
margin-bottom: 8px;
}
.question textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
margin-top: 10px;
}
.submit-btn {
display: block;
width: 100%;
padding: 15px;
background-color: #4CAF50;
color: white;
font-size: 18px;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 20px;
}
.submit-btn:hover {
background-color: #45a049;
}
.error {
color: red;
font-size: 14px;
text-align: center;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="survey-container">
<h1>Truth Survey</h1>
<form id="truthSurveyForm">
<div class="question">
<label for="q1">1. What is something you've never told anyone?</label>
<textarea name="q1" id="q1" rows="4" placeholder="Answer truthfully..."></textarea>
</div>
<div class="question">
<label for="q2">2. Have you ever lied to get out of trouble? If so, what was it?</label>
<textarea name="q2" id="q2" rows="4" placeholder="Answer truthfully..."></textarea>
</div>
<div class="question">
<label for="q3">3. What's the most embarrassing thing that has ever happened to you?</label>
<textarea name="q3" id="q3" rows="4" placeholder="Answer truthfully..."></textarea>
</div>
<div class="question">
<label for="q4">4. Who is your secret crush, if you have one?</label>
<textarea name="q4" id="q4" rows="4" placeholder="Answer truthfully..."></textarea>
</div>
<div class="question">
<label for="q5">5. Have you ever done something that you regret? What was it?</label>
<textarea name="q5" id="q5" rows="4" placeholder="Answer truthfully..."></textarea>
</div>
<button type="submit" class="submit-btn">Submit Survey</button>
<p class="error" id="error-message" style="display: none;">Please fill out all fields before submitting.</p>
</form>
</div>
<script>
const surveyForm = document.getElementById('truthSurveyForm');
const errorMessage = document.getElementById('error-message');
surveyForm.addEventListener('submit', function(event) {
event.preventDefault();
// Check if all text areas are filled
let allFilled = true;
const textAreas = surveyForm.querySelectorAll('textarea');
textAreas.forEach(textarea => {
if (textarea.value.trim() === '') {
allFilled = false;
}
});
// If any text area is empty, show an error message
if (!allFilled) {
errorMessage.style.display = 'block';
return;
} else {
errorMessage.style.display = 'none';
}
const formData = new FormData(surveyForm);
let responses = {};
// Collecting responses from the form
for (const [question, answer] of formData.entries()) {
responses[question] = answer; // Single answer for each question
}
// Store the responses in localStorage
localStorage.setItem('truthSurveyResponses', JSON.stringify(responses));
// Redirect to the results page
window.location.href = 'TRUTHRESPONSE.HTML'; // Modify this to the result page URL
});
</script>
</body>
</html>