Changed around line 1
+ document.getElementById('fitnessForm').addEventListener('submit', function(e) {
+ e.preventDefault();
+
+ const goal = document.getElementById('goal').value;
+ const level = document.getElementById('level').value;
+ const time = document.getElementById('time').value;
+
+ const plan = generatePlan(goal, level, time);
+ displayPlan(plan);
+ });
+
+ function generatePlan(goal, level, time) {
+ const plans = {
+ weightLoss: {
+ beginner: `Start with 30 minutes of brisk walking 3 times a week. Add 2 days of light strength training.`,
+ intermediate: `Combine 4 days of cardio (running, cycling) with 2 days of strength training.`,
+ advanced: `High-intensity interval training (HIIT) 4-5 times a week with strength training.`
+ },
+ muscleGain: {
+ beginner: `Focus on full-body workouts 3 times a week with light weights.`,
+ intermediate: `Split workouts (upper/lower body) 4 times a week with moderate weights.`,
+ advanced: `Targeted muscle group training 5-6 times a week with heavy weights.`
+ },
+ endurance: {
+ beginner: `Start with 20-30 minutes of steady-state cardio 3 times a week.`,
+ intermediate: `Increase to 45 minutes of cardio 4 times a week with interval training.`,
+ advanced: `Long-distance training 5 times a week with tempo runs.`
+ },
+ flexibility: {
+ beginner: `Daily stretching routine focusing on major muscle groups.`,
+ intermediate: `Yoga or Pilates 3-4 times a week.`,
+ advanced: `Advanced yoga or mobility training 5-6 times a week.`
+ }
+ };
+
+ let plan = plans[goal][level];
+
+ if (time == 3) {
+ plan = `For 3 hours/week: ${plan}`;
+ } else if (time == 5) {
+ plan = `For 5 hours/week: ${plan}`;
+ } else if (time == 7) {
+ plan = `For 7+ hours/week: ${plan}`;
+ }
+
+ return plan;
+ }
+
+ function displayPlan(plan) {
+ const resultSection = document.getElementById('resultSection');
+ const planResult = document.getElementById('planResult');
+
+ planResult.textContent = plan;
+ resultSection.style.display = 'block';
+ resultSection.scrollIntoView({ behavior: 'smooth' });
+ }