File: /home/aashishs/.trash/index.html.2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self';
connect-src 'self' https://script.google.com https://script.googleusercontent.com https://script.google.com/macros/s/*;
script-src 'self' 'unsafe-inline' 'unsafe-eval';
style-src 'self' 'unsafe-inline';
font-src 'self' data: https://fonts.gstatic.com;
img-src 'self' data: https:;">
<title>Mental Health Self-Assessment</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f9;
}
#container {
margin: 20px auto;
padding: 20px;
max-width: 800px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
h1,
h2 {
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
}
th {
background-color: #f4f4f9;
font-weight: bold;
}
td {
text-align: left;
}
.submit-button {
display: block;
width: 100%;
padding: 10px;
font-size: 16px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
.submit-button:hover {
background-color: #0056b3;
}
.page {
display: none;
}
.page.active {
display: block;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"],
input[type="number"],
input[type="tel"],
input[type="email"],
select,
textarea {
width: calc(100% - 12px);
padding: 6px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
#intro-page {
text-align: center;
padding: 20px;
}
#intro-page h2 {
margin-bottom: 10px;
}
#intro-page p {
margin-bottom: 20px;
}
#consent-page {
padding: 20px;
}
#consent-text {
text-align: justify;
margin-bottom: 20px;
}
#consent-contact {
margin-bottom: 20px;
}
/* Styles for page1 (Personal Details) */
#page1 {
padding: 20px;
}
#page1 label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
#page1 input[type="text"],
#page1 input[type="tel"],
#page1 input[type="email"],
#page1 select,
#page1 textarea {
width: calc(100% - 16px);
padding: 8px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
font-size: 16px;
}
#page1 textarea {
resize: vertical;
min-height: 100px;
}
#page1 select {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
background-image: url("data:image/svg+xml;utf8,<svg fill='black' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
background-repeat: no-repeat;
background-position: right 10px center;
padding-right: 30px;
}
#page1 input:invalid,
#page1 select:invalid {
border-color: red;
}
#page1 .submit-button {
margin-top: 20px;
}
.results-section {
background: #f9f9f9;
padding: 20px;
margin: 15px 0;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.results-section h3 {
color: #333;
margin-bottom: 15px;
border-bottom: 2px solid #ddd;
padding-bottom: 8px;
}
.score-interpretation {
margin-top: 10px;
padding: 10px;
background: #fff;
border-left: 4px solid #4CAF50;
border-radius: 4px;
}
.total-score {
background: #f0f7ff;
border: 2px solid #4CAF50;
}
#total-score {
font-size: 1.2em;
font-weight: bold;
color: #2196F3;
}
@media screen and (max-width: 768px) {
table {
display: block;
overflow-x: auto;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
}
th, td {
min-width: 120px; /* Minimum width for columns */
}
td:first-child {
min-width: 200px; /* Wider first column for questions */
max-width: 200px;
white-space: normal; /* Allow text wrapping in question column */
}
.results-section {
margin: 10px;
padding: 15px;
}
#container {
margin: 10px;
padding: 15px;
}
}
/* Optional: Add smooth scrolling for better UX */
table {
-webkit-overflow-scrolling: touch;
scroll-behavior: smooth;
}
/* Make radio buttons easier to tap on mobile */
input[type="radio"] {
min-width: 20px;
min-height: 20px;
margin: 8px;
}
</style>
</head>
<body>
<div id="container">
<div id="intro-page" class="page active">
<h2>Mental Health and Spirituality Level Self-Report Questionnaire</h2>
<p id="currentDate"></p>
<p>This questionnaire is a part of a research study that aims to investigate how mental health and
spirituality are interrelated among university students. Post survey you will receive your personalized
mental health report in your inbox (within 72 hours) as a token of gratitude for sharing your valuable
time for this study.</p>
<button type="button" id="start-now" class="submit-button">Start Now</button>
</div>
<div id="consent-page" class="page">
<h2>Informed Consent</h2>
<div id="consent-text">
<p>Please note the following before providing your consent to participate in this survey:</p>
<ul>
<li>Participation involves completing an online survey of approximately 7-10 minutes.</li>
<li>The survey is anonymous, and no personal identifiers will be used for research.</li>
<li>Your participation is entirely voluntary, and you can choose to withdraw at any time without
penalty or loss of benefits.</li>
<li>All responses will be kept confidential and anonymous. Data will be securely stored and
accessible only to the researcher and supervisor.</li>
<li>All data collected will be fully anonymized to protect participant confidentiality. No
personally identifiable information will be recorded, and data will not be shared with any
third-party entities.</li>
<li>For additional support and resources, please refer to the list of services provided at the end
of this survey.</li>
</ul>
<h3>Risks and Benefits</h3>
<p><strong>Risks:</strong> While the survey involves questions on mental health, which may cause
emotional discomfort, there are no significant risks to participating in this study.</p>
<p><strong>Benefits:</strong> While you will not receive direct benefits, your participation will
contribute to valuable insights into the mental health impacts of positive coping mechanisms like
spirituality on mental health. Participants will also get a detailed AI-generated stress level
assessment report for their personal reference on email.</p>
<div id="consent-contact">If you have any doubts or require clarification, please do not hesitate to
contact the facilitator.<br>
Ms. Sanna Masood<br>
Email ID: 23jibs-smasood@jgu.edu.in<br>
Contact number: +91-9469434177
</div>
</div>
<form id="consentForm">
<label><input type="radio" name="consent" value="agree" required> Agree</label><br>
<label><input type="radio" name="consent" value="disagree" required> Disagree</label><br><br>
<button type="button" id="consent-submit" class="submit-button">Submit</button>
</form>
</div>
<div id="page1" class="page">
<h2>Personal Details</h2>
<form id="infoForm">
<label for="gender">2. Gender:</label><br>
<select id="gender" name="gender" required>
<option value="">Select</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="non-binary">Non-binary</option>
<option value="prefer_not_to_say">Prefer not to say</option>
</select><br><br>
<label for="name">3. Name:</label><br>
<input type="text" id="name" name="name" required><br><br>
<label for="contact">4. Contact Number:</label><br>
<input type="tel" id="contact" name="contact" required><br><br>
<label for="email">5. Email ID (for sharing your report):</label><br>
<input type="email" id="email" name="email" required><br><br>
<label for="belief">6. Belief system - religious / spiritual identity:</label><br>
<select id="belief" name="belief" required>
<option value="">Select</option>
<option value="highly_religious">Highly Religious</option>
<option value="religious">Religious</option>
<option value="moderately_religious">Moderately Religious</option>
<option value="atheist">Atheist</option>
<option value="spiritual_non_religious">Spiritual but non-religious</option>
<option value="spiritual">Spiritual</option>
</select><br><br>
<label for="ideology">7. Briefly tell us about your belief ideology:</label><br>
<textarea id="ideology" name="ideology" rows="4"></textarea><br><br>
<button type="button" id="next1" class="submit-button">Next</button>
</form>
</div>
<div id="page3" class="page">
<h3>Sadness Levels (Past three months)</h3>
<form id="quiz">
<table id="sadnessTable">
<thead>
<tr>
<th>Statement</th>
<th>Never</th>
<th>Sometimes</th>
<th>Often</th>
<th>Mostly</th>
</tr>
</thead>
<tbody>
<tr>
<td>I couldn’t seem to experience any positive feeling</td>
<td><input type="radio" name="sadness_q1" value="0" required></td>
<td><input type="radio" name="sadness_q1" value="1" required></td>
<td><input type="radio" name="sadness_q1" value="2" required></td>
<td><input type="radio" name="sadness_q1" value="3" required></td>
</tr>
<tr>
<td>I found it difficult to work up the initiative to do things.</td>
<td><input type="radio" name="sadness_q2" value="0" required></td>
<td><input type="radio" name="sadness_q2" value="1" required></td>
<td><input type="radio" name="sadness_q2" value="2" required></td>
<td><input type="radio" name="sadness_q2" value="3" required></td>
</tr>
<tr>
<td>I felt that I had nothing to look forward to.</td>
<td><input type="radio" name="sadness_q3" value="0" required></td>
<td><input type="radio" name="sadness_q3" value="1" required></td>
<td><input type="radio" name="sadness_q3" value="2" required></td>
<td><input type="radio" name="sadness_q3" value="3" required></td>
</tr>
<tr>
<td>I felt down-hearted and blue</td>
<td><input type="radio" name="sadness_q4" value="0" required></td>
<td><input type="radio" name="sadness_q4" value="1" required></td>
<td><input type="radio" name="sadness_q4" value="2" required></td>
<td><input type="radio" name="sadness_q4" value="3" required></td>
</tr>
<tr>
<td>I was unable to become enthusiastic about anything.</td>
<td><input type="radio" name="sadness_q5" value="0" required></td>
<td><input type="radio" name="sadness_q5" value="1" required></td>
<td><input type="radio" name="sadness_q5" value="2" required></td>
<td><input type="radio" name="sadness_q5" value="3" required></td>
</tr>
<tr>
<td>I felt I wasn’t worth much as a person.</td>
<td><input type="radio" name="sadness_q6" value="0" required></td>
<td><input type="radio" name="sadness_q6" value="1" required></td>
<td><input type="radio" name="sadness_q6" value="2" required></td>
<td><input type="radio" name="sadness_q6" value="3" required></td>
</tr>
<tr>
<td>I felt that life was meaningless</td>
<td><input type="radio" name="sadness_q7" value="0" required></td>
<td><input type="radio" name="sadness_q7" value="1" required></td>
<td><input type="radio" name="sadness_q7" value="2" required></td>
<td><input type="radio" name="sadness_q7" value="3" required></td>
</tr>
</tbody>
</table>
<h3>Anxiety Levels (Past three months)</h3>
<table id="anxietyTable">
<thead>
<tr>
<th>Statement</th>
<th>Never</th>
<th>Sometimes</th>
<th>Often</th>
<th>Mostly</th>
</tr>
</thead>
<tbody>
<tr>
<td>I was aware of the dryness of my mouth.</td>
<td><input type="radio" name="anxiety_q1" value="0" required></td>
<td><input type="radio" name="anxiety_q1" value="1" required></td>
<td><input type="radio" name="anxiety_q1" value="2" required></td>
<td><input type="radio" name="anxiety_q1" value="3" required></td>
</tr>
<tr>
<td>I experienced breathing difficulty (e.g., excessively rapid breathing, breathlessness in
the absence of physical exertion).</td>
<td><input type="radio" name="anxiety_q2" value="0" required></td>
<td><input type="radio" name="anxiety_q2" value="1" required></td>
<td><input type="radio" name="anxiety_q2" value="2" required></td>
<td><input type="radio" name="anxiety_q2" value="3" required></td>
</tr>
<tr>
<td>I experienced trembling (e.g., in the hands).</td>
<td><input type="radio" name="anxiety_q3" value="0" required></td>
<td><input type="radio" name="anxiety_q3" value="1" required></td>
<td><input type="radio" name="anxiety_q3" value="2" required></td>
<td><input type="radio" name="anxiety_q3" value="3" required></td>
</tr>
<tr>
<td>I was worried about situations in which I might panic and make a fool of myself.</td>
<td><input type="radio" name="anxiety_q4" value="0" required></td>
<td><input type="radio" name="anxiety_q4" value="1" required></td>
<td><input type="radio" name="anxiety_q4" value="2" required></td>
<td><input type="radio" name="anxiety_q4" value="3" required></td>
</tr>
<tr>
<td>I felt I was close to panic.</td>
<td><input type="radio" name="anxiety_q5" value="0" required></td>
<td><input type="radio" name="anxiety_q5" value="1" required></td>
<td><input type="radio" name="anxiety_q5" value="2" required></td>
<td><input type="radio" name="anxiety_q5" value="3" required></td>
</tr>
<tr>
<td>I was aware of the action of my heart in the absence of physical exertion (e.g., sense
of heart rate increase, heart missing a beat).</td>
<td><input type="radio" name="anxiety_q6" value="0" required></td>
<td><input type="radio" name="anxiety_q6" value="1" required></td>
<td><input type="radio" name="anxiety_q6" value="2" required></td>
<td><input type="radio" name="anxiety_q6" value="3" required></td>
</tr>
<tr>
<td>I felt scared without any good reason.</td>
<td><input type="radio" name="anxiety_q7" value="0" required></td>
<td><input type="radio" name="anxiety_q7" value="1" required></td>
<td><input type="radio" name="anxiety_q7" value="2" required></td>
<td><input type="radio" name="anxiety_q7" value="3" required></td>
</tr>
</tbody>
</table>
<h3>Stress Levels (Past one month)</h3>
<table id="stressTable">
<thead>
<tr>
<th>Statement</th>
<th>Never</th>
<th>Sometimes</th>
<th>Often</th>
<th>Mostly</th>
</tr>
</thead>
<tbody>
<tr>
<td>I found it hard to finish my tasks.</td>
<td><input type="radio" name="stress_q1" value="0" required></td>
<td><input type="radio" name="stress_q1" value="1" required></td>
<td><input type="radio" name="stress_q1" value="2" required></td>
<td><input type="radio" name="stress_q1" value="3" required></td>
</tr>
<tr>
<td>I tended to over-react to situations.</td>
<td><input type="radio" name="stress_q2" value="0" required></td>
<td><input type="radio" name="stress_q2" value="1" required></td>
<td><input type="radio" name="stress_q2" value="2" required></td>
<td><input type="radio" name="stress_q2" value="3" required></td>
</tr>
<tr>
<td>I felt that I was feeling very nervous.</td>
<td><input type="radio" name="stress_q3" value="0" required></td>
<td><input type="radio" name="stress_q3" value="1" required></td>
<td><input type="radio" name="stress_q3" value="2" required></td>
<td><input type="radio" name="stress_q3" value="3" required></td>
</tr>
<tr>
<td>I found myself getting agitated.</td>
<td><input type="radio" name="stress_q4" value="0" required></td>
<td><input type="radio" name="stress_q4" value="1" required></td>
<td><input type="radio" name="stress_q4" value="2" required></td>
<td><input type="radio" name="stress_q4" value="3" required></td>
</tr>
<tr>
<td>I found it difficult to relax.</td>
<td><input type="radio" name="stress_q5" value="0" required></td>
<td><input type="radio" name="stress_q5" value="1" required></td>
<td><input type="radio" name="stress_q5" value="2" required></td>
<td><input type="radio" name="stress_q5" value="3" required></td>
</tr>
<tr>
<td>I was intolerant of anything that kept me from getting on with what I was doing.</td>
<td><input type="radio" name="stress_q6" value="0" required></td>
<td><input type="radio" name="stress_q6" value="1" required></td>
<td><input type="radio" name="stress_q6" value="2" required></td>
<td><input type="radio" name="stress_q6" value="3" required></td>
</tr>
<tr>
<td>I felt that I was rather touchy.</td>
<td><input type="radio" name="stress_q7" value="0" required></td>
<td><input type="radio" name="stress_q7" value="1" required></td>
<td><input type="radio" name="stress_q7" value="2" required></td>
<td><input type="radio" name="stress_q7" value="3" required></td>
</tr>
</tbody>
</table>
<h3>Coping Mechanisms</h3>
<table id="copingTable">
<thead>
<tr>
<th>Statement</th>
<th>Rarely</th>
<th>Sometimes</th>
<th>Often</th>
<th>Mostly</th>
</tr>
</thead>
<tbody>
<tr>
<td>I’ve been concentrating my efforts on doing something about the situation I’m in.</td>
<td><input type="radio" name="coping_q1" value="0" required></td>
<td><input type="radio" name="coping_q1" value="1" required></td>
<td><input type="radio" name="coping_q1" value="2" required></td>
<td><input type="radio" name="coping_q1" value="3" required></td>
</tr>
<tr>
<td>I’ve been trying to see it in a different light, to make it seem more positive.</td>
<td><input type="radio" name="coping_q2" value="0" required></td>
<td><input type="radio" name="coping_q2" value="1" required></td>
<td><input type="radio" name="coping_q2" value="2" required></td>
<td><input type="radio" name="coping_q2" value="3" required></td>
</tr>
<tr>
<td>I’ve been using alcohol or other drugs to make myself feel better.</td>
<td><input type="radio" name="coping_q3" value="0" required></td>
<td><input type="radio" name="coping_q3" value="1" required></td>
<td><input type="radio" name="coping_q3" value="2" required></td>
<td><input type="radio" name="coping_q3" value="3" required></td>
</tr>
<tr>
<td>I’ve been saying to myself “this isn’t real.”</td>
<td><input type="radio" name="coping_q4" value="0" required></td>
<td><input type="radio" name="coping_q4" value="1" required></td>
<td><input type="radio" name="coping_q4" value="2" required></td>
<td><input type="radio" name="coping_q4" value="3" required></td>
</tr>
<tr>
<td>I’ve been getting emotional support from others.</td>
<td><input type="radio" name="coping_q5" value="0" required></td>
<td><input type="radio" name="coping_q5" value="1" required></td>
<td><input type="radio" name="coping_q5" value="2" required></td>
<td><input type="radio" name="coping_q5" value="3" required></td>
</tr>
<tr>
<td>I’ve been giving up the attempt to cope.</td>
<td><input type="radio" name="coping_q6" value="0" required></td>
<td><input type="radio" name="coping_q6" value="1" required></td>
<td><input type="radio" name="coping_q6" value="2" required></td>
<td><input type="radio" name="coping_q6" value="3" required></td>
</tr>
<tr>
<td>I’ve been taking action to try to make the situation better.</td>
<td><input type="radio" name="coping_q7" value="0" required></td>
<td><input type="radio" name="coping_q7" value="1" required></td>
<td><input type="radio" name="coping_q7" value="2" required></td>
<td><input type="radio" name="coping_q7" value="3" required></td>
</tr>
<tr>
<td>I’ve been criticizing myself.</td>
<td><input type="radio" name="coping_q8" value="0" required></td>
<td><input type="radio" name="coping_q8" value="1" required></td>
<td><input type="radio" name="coping_q8" value="2" required></td>
<td><input type="radio" name="coping_q8" value="3" required></td>
</tr>
<tr>
<td>I’ve been trying to find comfort in my religion or spiritual beliefs.</td>
<td><input type="radio" name="coping_q9" value="0" required></td>
<td><input type="radio" name="coping_q9" value="1" required></td>
<td><input type="radio" name="coping_q9" value="2" required></td>
<td><input type="radio" name="coping_q9" value="3" required></td>
</tr>
<tr>
<td>I’ve been looking for something good in what is happening.</td>
<td><input type="radio" name="coping_q10" value="0" required></td>
<td><input type="radio" name="coping_q10" value="1" required></td>
<td><input type="radio" name="coping_q10" value="2" required></td>
<td><input type="radio" name="coping_q10" value="3" required></td>
</tr>
<tr>
<td>I’ve been learning to live with it.</td>
<td><input type="radio" name="coping_q11" value="0" required></td>
<td><input type="radio" name="coping_q11" value="1" required></td>
<td><input type="radio" name="coping_q11" value="2" required></td>
<td><input type="radio" name="coping_q11" value="3" required></td>
</tr>
<tr>
<td>I’ve been making jokes about the situation.</td>
<td><input type="radio" name="coping_q12" value="0" required></td>
<td><input type="radio" name="coping_q12" value="1" required></td>
<td><input type="radio" name="coping_q12" value="2" required></td>
<td><input type="radio" name="coping_q12" value="3" required></td>
</tr>
<tr>
<td>I’ve been turning to work or other activities to take my mind off things.</td>
<td><input type="radio" name="coping_q13" value="0" required></td>
<td><input type="radio" name="coping_q13" value="1" required></td>
<td><input type="radio" name="coping_q13" value="2" required></td>
<td><input type="radio" name="coping_q13" value="3" required></td>
</tr>
<tr>
<td>I’ve been getting help and advice from other people.</td>
<td><input type="radio" name="coping_q14" value="0" required></td>
<td><input type="radio" name="coping_q14" value="1" required></td>
<td><input type="radio" name="coping_q14" value="2" required></td>
<td><input type="radio" name="coping_q14" value="3" required></td>
</tr>
</tbody>
</table>
<h3>Connection with others, environment and universe</h3>
<table id="connectionTable">
<thead>
<tr>
<th>Statement</th>
<th>Strongly Agree</th>
<th>Agree</th>
<th>Neutral</th>
<th>Disagree</th>
<th>Strongly Disagree</th>
</tr>
</thead>
<tbody>
<tr>
<td>I feel a deep sense of connection with a higher power or the universe.</td>
<td><input type="radio" name="connection_q1" value="0" required></td>
<td><input type="radio" name="connection_q1" value="1" required></td>
<td><input type="radio" name="connection_q1" value="2" required></td>
<td><input type="radio" name="connection_q1" value="3" required></td>
<td><input type="radio" name="connection_q1" value="4" required></td>
</tr>
<tr>
<td>I often feel a sense of harmony or oneness with the world or the people around me.</td>
<td><input type="radio" name="connection_q2" value="0" required></td>
<td><input type="radio" name="connection_q2" value="1" required></td>
<td><input type="radio" name="connection_q2" value="2" required></td>
<td><input type="radio" name="connection_q2" value="3" required></td>
<td><input type="radio" name="connection_q2" value="4" required></td>
</tr>
<tr>
<td>I engage in practices that nurture me (e.g., prayer, meditation, reflection).</td>
<td><input type="radio" name="connection_q3" value="0" required></td>
<td><input type="radio" name="connection_q3" value="1" required></td>
<td><input type="radio" name="connection_q3" value="2" required></td>
<td><input type="radio" name="connection_q3" value="3" required></td>
<td><input type="radio" name="connection_q3" value="4" required></td>
</tr>
<tr>
<td>My spiritual practices help me feel calm and at peace.</td>
<td><input type="radio" name="connection_q4" value="0" required></td>
<td><input type="radio" name="connection_q4" value="1" required></td>
<td><input type="radio" name="connection_q4" value="2" required></td>
<td><input type="radio" name="connection_q4" value="3" required></td>
<td><input type="radio" name="connection_q4" value="4" required></td>
</tr>
<tr>
<td>I experience moments of transcendence or profound insight.</td>
<td><input type="radio" name="connection_q5" value="0" required></td>
<td><input type="radio" name="connection_q5" value="1" required></td>
<td><input type="radio" name="connection_q5" value="2" required></td>
<td><input type="radio" name="connection_q5" value="3" required></td>
<td><input type="radio" name="connection_q5" value="4" required></td>
</tr>
<tr>
<td>I find comfort and strength in my spiritual beliefs during difficult times.</td>
<td><input type="radio" name="connection_q6" value="0" required></td>
<td><input type="radio" name="connection_q6" value="1" required></td>
<td><input type="radio" name="connection_q6" value="2" required></td>
<td><input type="radio" name="connection_q6" value="3" required></td>
<td><input type="radio" name="connection_q6" value="4" required></td>
</tr>
<tr>
<td>My beliefs or values inspire me to contribute positively to the lives of others or
society.</td>
<td><input type="radio" name="connection_q7" value="0" required></td>
<td><input type="radio" name="connection_q7" value="1" required></td>
<td><input type="radio" name="connection_q7" value="2" required></td>
<td><input type="radio" name="connection_q7" value="3" required></td>
<td><input type="radio" name="connection_q7" value="4" required></td>
</tr>
<tr>
<td>I strive to live in alignment with principles that reflect my deepest sense of what is
meaningful.</td>
<td><input type="radio" name="connection_q8" value="0" required></td>
<td><input type="radio" name="connection_q8" value="1" required></td>
<td><input type="radio" name="connection_q8" value="2" required></td>
<td><input type="radio" name="connection_q8" value="3" required></td>
<td><input type="radio" name="connection_q8" value="4" required></td>
</tr>
</tbody>
</table>
<button type="submit" class="submit-button">Submit</button>
</form>
</div>
<div id="results" class="page">
<h2>Results</h2>
<div class="results-section">
<h3>Sadness Level</h3>
<p id="sadness-score"></p>
<div class="score-interpretation" id="sadness-interpretation"></div>
</div>
<div class="results-section">
<h3>Anxiety Level</h3>
<p id="anxiety-score"></p>
<div class="score-interpretation" id="anxiety-interpretation"></div>
</div>
<div class="results-section">
<h3>Stress Level</h3>
<p id="stress-score"></p>
<div class="score-interpretation" id="stress-interpretation"></div>
</div>
<div class="results-section">
<h3>Coping Mechanisms</h3>
<p id="coping-score"></p>
<div class="score-interpretation" id="coping-interpretation"></div>
</div>
<div class="results-section">
<h3>Connection Level</h3>
<p id="connection-score"></p>
<div class="score-interpretation" id="connection-interpretation"></div>
</div>
<div class="results-section total-score">
<h3>Overall Assessment</h3>
<p id="total-score"></p>
<div class="score-interpretation" id="total-interpretation"></div>
</div>
</div>
</div>
<script>
const pages = document.querySelectorAll('.page');
let currentPage = 0;
function showPage(pageIndex) {
pages.forEach((page, index) => {
page.classList.toggle('active', index === pageIndex);
});
currentPage = pageIndex;
}
// Date display
const today = new Date();
const options = {
year: 'numeric',
month: 'long',
day: 'numeric'
};
const formattedDate = today.toLocaleDateString('en-US', options);
document.getElementById('currentDate').textContent = formattedDate;
document.getElementById('start-now').addEventListener('click', () => {
showPage(1);
});
document.getElementById('consent-submit').addEventListener('click', () => {
if (document.getElementById('consentForm').checkValidity()) {
const consentValue = document.querySelector('input[name="consent"]:checked').value;
if (consentValue === 'agree') {
showPage(2);
} else {
alert("You must agree to the consent to proceed.");
}
}
});
document.getElementById('next1').addEventListener('click', () => {
if (document.getElementById('infoForm').checkValidity()) {
showPage(3);
}
});
document.getElementById('quiz').addEventListener('submit', function (event) {
event.preventDefault();
try {
// Calculate scores
const sadnessScore = calculateSectionScore('sadness', 7);
const anxietyScore = calculateSectionScore('anxiety', 7);
const stressScore = calculateSectionScore('stress', 7);
const copingScore = calculateSectionScore('coping', 14);
const connectionScore = calculateSectionScore('connection', 8);
const totalScore = sadnessScore + anxietyScore + stressScore + copingScore + connectionScore;
// Create FormData
const formData = new FormData();
// Add personal info
formData.append('name', document.getElementById('name').value);
formData.append('email', document.getElementById('email').value);
formData.append('contact', document.getElementById('contact').value);
formData.append('gender', document.getElementById('gender').value);
formData.append('belief', document.getElementById('belief').value);
formData.append('ideology', document.getElementById('ideology').value);
// Add individual question responses
// Sadness questions
for(let i = 1; i <= 7; i++) {
formData.append(`sadness_q${i}`, document.querySelector(`input[name="sadness_q${i}"]:checked`).value);
}
// Anxiety questions
for(let i = 1; i <= 7; i++) {
formData.append(`anxiety_q${i}`, document.querySelector(`input[name="anxiety_q${i}"]:checked`).value);
}
// Stress questions
for(let i = 1; i <= 7; i++) {
formData.append(`stress_q${i}`, document.querySelector(`input[name="stress_q${i}"]:checked`).value);
}
// Coping questions
for(let i = 1; i <= 14; i++) {
formData.append(`coping_q${i}`, document.querySelector(`input[name="coping_q${i}"]:checked`).value);
}
// Connection questions
for(let i = 1; i <= 8; i++) {
formData.append(`connection_q${i}`, document.querySelector(`input[name="connection_q${i}"]:checked`).value);
}
// Add scores
formData.append('sadnessScore', sadnessScore);
formData.append('anxietyScore', anxietyScore);
formData.append('stressScore', stressScore);
formData.append('copingScore', copingScore);
formData.append('connectionScore', connectionScore);
formData.append('totalScore', totalScore);
// Debug log
console.log('Form data being sent:', Object.fromEntries(formData));
// Submit to database
fetch('submit.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if(data.status === 'success') {
console.log('Data saved successfully');
showPage(4); // Show results page
} else {
console.error('Error saving data:', data.message);
alert('There was an error saving your responses. Please try again.');
}
})
.catch(error => {
console.error('Error:', error);
alert('There was an error submitting the form. Please try again.');
});
} catch (error) {
console.error('Error:', error);
alert('There was an error processing your responses. Please try again.');
}
});
const interpretScore = (score) => {
if (score < 10) return "Your mental wellbeing seems to be in a good state.";
if (score < 20) return "You may be experiencing some challenges. Consider seeking support if needed.";
return "Your mental wellbeing requires attention. Reach out to a mental health professional.";
};
function calculateSectionScore(prefix, count) {
let score = 0;
try {
for (let i = 1; i <= count; i++) {
const input = document.querySelector(`input[name="${prefix}_q${i}"]:checked`);
if (input) {
score += parseInt(input.value);
}
}
} catch (error) {
console.log(`Error calculating ${prefix} score:`, error);
}
return score;
}
function getInterpretation(score, max, type) {
const percentage = (score / max) * 100;
if (type === 'coping' || type === 'connection') {
if (percentage >= 75) return "Excellent level of " + type;
if (percentage >= 50) return "Good level of " + type;
if (percentage >= 25) return "Fair level of " + type;
return "Could improve " + type + " strategies";
} else {
if (percentage >= 75) return "Severe level of " + type;
if (percentage >= 50) return "Moderate level of " + type;
if (percentage >= 25) return "Mild level of " + type;
return "Normal level of " + type;
}
}
// Update the display functions to check if elements exist
function updateScoreDisplay(elementId, text) {
const element = document.getElementById(elementId);
if (element) {
element.textContent = text;
}
}
showPage(0);
</script>
</body>
</html>