Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
autopopulation for Year and Month defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
dotMavriQ committed Mar 28, 2024
1 parent c91cb36 commit 1596c38
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,27 @@ document.getElementById('print').addEventListener('click', function() {
console.error('Failed to copy results: ', err);
});
});
document.addEventListener('DOMContentLoaded', function() {
const now = new Date();
const currentYear = now.getFullYear();
const currentMonth = now.getMonth() + 1; // JavaScript months are 0-indexed

// Populate year dropdown dynamically or set the current year as selected
const yearSelect = document.getElementById('year');
for (let year = currentYear; year <= currentYear + 5; year++) { // Example range: current year to current year + 5
const option = document.createElement('option');
option.value = year;
option.text = year;
option.selected = year === currentYear;
yearSelect.appendChild(option);
}

// Set the current month as selected
const monthSelect = document.getElementById('month');
monthSelect.value = currentMonth;

// Your existing code to handle the "PRINT" button click...
document.getElementById('print').addEventListener('click', function() {
// Existing functionality...
});
});

0 comments on commit 1596c38

Please sign in to comment.