document.addEventListener('DOMContentLoaded', function () {
document.getElementById('study-plan-form').addEventListener('submit', function (e) {
e.preventDefault();const subjectsInput = document.getElementById('subjects').value;
const durationInput = document.getElementById('duration').value;
const goalInput = document.getElementById('goal').value;const subjects = subjectsInput.split(',').map(subject => subject.trim());
const totalDuration = parseInt(durationInput, 10);
const goal = goalInput;if (subjects.length === 0 || totalDuration <= 0) {
alert('Please enter valid subjects and duration.');
return;
}const hoursPerSubject = (totalDuration / subjects.length).toFixed(2);
let studyPlan = `Your Study Plan
Goal: ${goal}
Total Duration: ${totalDuration} hours
`;
subjects.forEach(subject => {
studyPlan += `- ${subject}: ${hoursPerSubject} hours
`;
});
studyPlan += '
';document.getElementById('result').innerHTML = studyPlan;
});
});