Changed around line 1
+ document.addEventListener('DOMContentLoaded', function() {
+ const form = document.getElementById('decisionForm');
+ const resultSection = document.getElementById('result');
+ const recommendationText = document.querySelector('.recommendation-text');
+ const retakeButton = document.getElementById('retake');
+
+ // Update range values
+ const rangeInputs = document.querySelectorAll('input[type="range"]');
+ rangeInputs.forEach(input => {
+ const valueDisplay = input.nextElementSibling;
+ valueDisplay.textContent = input.value;
+
+ input.addEventListener('input', () => {
+ valueDisplay.textContent = input.value;
+ });
+ });
+
+ form.addEventListener('submit', function(e) {
+ e.preventDefault();
+
+ // Get values
+ const passion = parseInt(document.getElementById('passion').value);
+ const career = parseInt(document.getElementById('career').value);
+ const financial = parseInt(document.getElementById('financial').value);
+
+ // Calculate scores
+ const phdScore = passion * 0.6 + (10 - career) * 0.2 + (10 - financial) * 0.2;
+ const workScore = (10 - passion) * 0.2 + career * 0.6 + financial * 0.2;
+
+ // Show result
+ form.classList.add('hidden');
+ resultSection.classList.remove('hidden');
+
+ // Draw chart
+ const ctx = document.getElementById('decisionChart').getContext('2d');
+ new Chart(ctx, {
+ type: 'bar',
+ data: {
+ labels: ['PhD', 'Work'],
+ datasets: [{
+ label: 'Recommendation Score',
+ data: [phdScore, workScore],
+ backgroundColor: [
+ 'rgba(74, 144, 226, 0.8)',
+ 'rgba(80, 227, 194, 0.8)'
+ ],
+ borderColor: [
+ 'rgba(74, 144, 226, 1)',
+ 'rgba(80, 227, 194, 1)'
+ ],
+ borderWidth: 1
+ }]
+ },
+ options: {
+ scales: {
+ y: {
+ beginAtZero: true,
+ max: 10
+ }
+ },
+ responsive: true,
+ maintainAspectRatio: false
+ }
+ });
+
+ // Show recommendation text
+ if (phdScore > workScore) {
+ recommendationText.textContent = "Based on your answers, pursuing a PhD might be the better choice for you.";
+ } else {
+ recommendationText.textContent = "Based on your answers, entering the workforce might be the better choice for you.";
+ }
+ });
+
+ retakeButton.addEventListener('click', function() {
+ resultSection.classList.add('hidden');
+ form.classList.remove('hidden');
+ });
+ });