7643ed5e938d46eca99b64df29392618)
Make Him Love You
document.addEventListener("DOMContentLoaded", function () { const quiz = document.getElementById("attachment-quiz"); const button = document.getElementById("attachment-quiz-submit"); if (!quiz || !button) return; button.addEventListener("click", function () { const scores = { secure: 0, anxious: 0, avoidant: 0, fearful: 0 }; const message = quiz.querySelector("#attachment-quiz-message"); for (let i = 1; i <= 12; i++) { const answer = quiz.querySelector( 'input[name="q' + i + '"]:checked' ); if (!answer) { message.textContent = "Please answer all 12 questions before seeing your result."; quiz.querySelector( '.quiz-question input[name="q' + i + '"]' ).closest(".quiz-question").scrollIntoView({ behavior: "smooth", block: "center" }); return; } scores[answer.value]++; } const names = { secure: "Secure Attachment", anxious: "Anxious Attachment", avoidant: "Avoidant Attachment", fearful: "Fearful-Avoidant Attachment" }; const ranked = Object.keys(scores).sort( (a, b) => scores[b] - scores[a] ); const first = ranked[0]; const second = ranked[1]; let result = names[first]; if (scores[first] - scores[second] <= 1) { result += " and " + names[second]; } message.textContent = "Your result: " + result + ". This quiz is for self-reflection, not diagnosis."; }); });