I'm working on application forms for our university and one of the fields is a drop down box that list 5 years (2001, 2002, ...., 2005) that would start from the current year. I would like to avoid having to manually update the drop down each year. I found the JavaScript code but I am not sure how to use it to replace my current "year" option Qualtrics question.
I am not a whiz when it comes to coding and have inserted some basic jQuery/JavaScript that I found that has been extremely helpful but I can't figure this one out .... can someone please advise how to get the following code into my question or please provide me a source?
<script type="text/javascript"><!--
var HowManyListItems = 5; // Specify number of "year" selections.
var year = new Date().getFullYear();
for(var i = 0; i < HowManyListItems; i++)
{
var t = i + year;
document.write('<option value="' + t + '">' + t + '</option>');
}
//--></script>
The code output would be which will change each year thereafter automatically:
2019
2020
2021
2022
2023
Any help you could provide would be greatly appreciated!
Best regards,
Rose
Best answer by TomG
View original