Conversation
to-do-notifications/scripts/todo.js
Outdated
| year.value = 2026; | ||
| day.value = "01"; | ||
| month.value = "January"; | ||
| year.value = new Date().getFullYear(); |
There was a problem hiding this comment.
I've changed this line (instead of hard-coding it to a year)
to-do-notifications/index.html
Outdated
| <option value="2018">2018</option> | ||
| <option value="2019">2019</option> | ||
| <option value="2020">2020</option> | ||
| <option value="2021">2021</option> | ||
| <option value="2022">2022</option> | ||
| <option value="2023">2023</option> | ||
| <option value="2024">2024</option> | ||
| <option value="2025">2025</option> | ||
| <option value="2026">2026</option> | ||
| <option value="2027">2027</option> | ||
| <option value="2028">2028</option> | ||
| <option value="2029">2029</option> | ||
| <option value="2030">2030</option> |
There was a problem hiding this comment.
reordered this list to be in ascending order
There was a problem hiding this comment.
Looks good! Thank you 😊
I have another idea: we can avoid changing the dates altogether, even in 2030!
This will generate a list of 13 options, starting with the current year (2026–2038)
// Populate year options: current year and 12 years into the future
const currentYear = new Date().getFullYear();
for (let i = 0; i <= 12; i++) {
const option = document.createElement("option");
const yearValue = currentYear + i;
option.value = yearValue;
option.textContent = yearValue;
year.appendChild(option);
}And then we set it:
year.value = currentYear;I would remove all the pre-filled years from HTML too and leave the <select> empty.
I wish I could’ve suggested it, but GitHub won’t allow it 🥲
|
Sorry it took me a while to get back to this task. I've added 2 more files to this PR:
I'll open a content PR to make sure the tutorial there reflects the same code. |
This is a follow up to #371, which was loading 2030 as the starting year in the form, picking from the first option in the HTML drop-down list.
This PR:
Motivation
To avoid future updates to this UI every time the year changes
Additional details
The app link can be accessed at https://mdn.github.io/dom-examples/to-do-notifications/