Changed around line 1
+ document.getElementById('familyTreeForm').addEventListener('submit', function(event) {
+ event.preventDefault();
+
+ const familyName = document.getElementById('familyName').value;
+ const firstName = document.getElementById('firstName').value;
+
+ const familyMembers = generateFamilyTree(familyName, firstName);
+
+ const familyMembersList = document.getElementById('familyMembers');
+ familyMembersList.innerHTML = '';
+
+ familyMembers.forEach(member => {
+ const li = document.createElement('li');
+ li.textContent = `${member.name} - ${member.relationship}`;
+ familyMembersList.appendChild(li);
+ });
+
+ document.getElementById('familyTree').classList.remove('hidden');
+ });
+
+ function generateFamilyTree(familyName, firstName) {
+ const relationships = [
+ 'Grandfather', 'Grandmother', 'Father', 'Mother', 'Uncle', 'Aunt', 'Brother', 'Sister', 'Cousin', 'Nephew'
+ ];
+
+ const firstNames = ['John', 'Jane', 'Michael', 'Emily', 'David', 'Sarah', 'James', 'Emma', 'William', 'Olivia'];
+ const lastNames = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis', 'Rodriguez', 'Martinez'];
+
+ const familyMembers = [];
+
+ for (let i = 0; i < 10; i++) {
+ const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
+ const randomLastName = lastNames[Math.floor(Math.random() * lastNames.length)];
+ const relationship = relationships[i];
+
+ familyMembers.push({
+ name: `${randomFirstName} ${randomLastName}`,
+ relationship: relationship
+ });
+ }
+
+ return familyMembers;
+ }