From 0a43aee75bd38c5ddbee143282372b2128f608fd Mon Sep 17 00:00:00 2001 From: Jesper Ordrup Date: Fri, 24 Jan 2025 18:42:36 +0100 Subject: [PATCH] select all and save to session --- weekdays.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/weekdays.html b/weekdays.html index 1e3f1f2..b992d17 100644 --- a/weekdays.html +++ b/weekdays.html @@ -445,6 +445,9 @@

Friday

const dropdown = document.getElementById('nameDropdown'); distinctNames.forEach((name) => { const option = document.createElement('option'); + if(name === '' || name === null) { + return; + } option.value = name; option.textContent = name; dropdown.appendChild(option); @@ -455,11 +458,19 @@

Friday

const selectedName = event.target.value; console.log('Selected:', selectedName); window.currentAssigned = selectedName; + sessionStorage.setItem('lastSelectedName', selectedName); + if(selectedName === '') { + window.currentAssigned = null; + } runthis(window.currentStartDay, window.currentAssigned); } // Attach event listener dropdown.addEventListener('change', handleChange); + const lastSelectedName = sessionStorage.getItem('lastSelectedName'); + if (lastSelectedName) { + dropdown.value = lastSelectedName; + } function getUniqueAssignedValues(entries) { const assignedValues = entries.map((entry) => entry.assigned); // Extract assigned values