Skip to content

Instantly share code, notes, and snippets.

@modium
Created January 19, 2020 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save modium/321831eae3fb64c46240fb3f1d7347f7 to your computer and use it in GitHub Desktop.
Save modium/321831eae3fb64c46240fb3f1d7347f7 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<select id='date-dropdown'>
</select>
<script>
let dateDropdown = document.getElementById('date-dropdown');
let currentYear = new Date().getFullYear();
let earliestYear = 1970;
while (currentYear >= earliestYear) {
let dateOption = document.createElement('option');
dateOption.text = currentYear;
dateOption.value = currentYear;
dateDropdown.add(dateOption);
currentYear -= 1;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment