Changed around line 1
+ document.addEventListener('DOMContentLoaded', function () {
+ const pollForm = document.getElementById('poll-form');
+ const optionsContainer = document.getElementById('options-container');
+ const addOptionButton = document.getElementById('add-option');
+ const pollDisplay = document.getElementById('poll-display');
+ const pollResults = document.getElementById('poll-results');
+ const resetPollButton = document.getElementById('reset-poll');
+
+ let optionCount = 1;
+
+ addOptionButton.addEventListener('click', function () {
+ optionCount++;
+ const newOption = document.createElement('div');
+ newOption.classList.add('option');
+ newOption.innerHTML = `
+
+ ×
+ `;
+ optionsContainer.appendChild(newOption);
+ });
+
+ optionsContainer.addEventListener('click', function (e) {
+ if (e.target.classList.contains('remove-option')) {
+ e.target.parentElement.remove();
+ optionCount--;
+ }
+ });
+
+ pollForm.addEventListener('submit', function (e) {
+ e.preventDefault();
+ const question = document.getElementById('poll-question').value;
+ const options = Array.from(document.querySelectorAll('.option-input')).map(input => input.value);
+
+ pollResults.innerHTML = `
+
${question} + ${options.map(option => `
${option} `).join('')}+
+ `;
+
+ pollForm.reset();
+ optionsContainer.innerHTML = `
+ Poll Options:
+ `;
+ optionCount = 1;
+
+ pollDisplay.classList.remove('hidden');
+ pollForm.classList.add('hidden');
+ });
+
+ resetPollButton.addEventListener('click', function () {
+ pollDisplay.classList.add('hidden');
+ pollForm.classList.remove('hidden');
+ });
+ });