I want to update an anchor button's href value when the associated drop-down list is updated to a different value. I try to change the menu item and I get an error telling me that the value of the selected list item is undefined, even though at the beginning there are defined values. Even submitting the default values does not work. If someone could assist me with what I am doing wrong that would be greatly appreciated.
Sample of an HTML div I'm trying to get to work (There are several divs on the page like this, which is why I'm using the class list in the JS instead of the ID):
<div class="yearcontainer catalogue">
<h2>CCRC 2017 Meeting Minutes</h2>
<div class="listgui">
<label for="2017input">Select from the 2017 list: </label>
<select id="2017input" class="dropdowns" name="2017input">
<option value="files/2017/010417.pdf">January 4, 2017</option>
<option value="files/2017/010417 Budget Workshop.pdf">January 4, 2017 Workshop</option>
<option value="files/2017/020317.pdf">February 3, 2017</option>
<option value="files/2017/021517.pdf">February 15, 2017</option>
<option value="files/2017/030117.pdf">March 1, 2017</option>
<option value="files/2017/040517.pdf">April 5, 2017</option>
<option value="files/2017/041917.pdf">April 19, 2017</option>
<option value="files/2017/050317 rev.pdf">May 3, 2017</option>
<option value="files/2017/060717.pdf">June 7, 2017</option>
<option value="files/2017/070517.pdf">July 5, 2017</option>
<option value="files/2017/080217.pdf">August 2, 2017</option>
<option value="files/2017/090617.pdf">September 6, 2017</option>
<option value="files/2017/092717.pdf">September 27, 2017</option>
<option value="files/2017/100317 Workshop.pdf">October 3, 2017 Workshop</option>
<option value="files/2017/110117.pdf">November 1, 2017</option>
<option value="files/2017/120617.pdf">December 6, 2017</option>
</select>
<a href="" class="onpagelink" target="_blank">Go..</a>
</div>
</div>
And the associated JS:
var linkButtons = document.querySelectorAll(".onpagelink");
var linkDropDowns = document.querySelectorAll(".dropdowns");
for(i=0; i<linkDropDowns.length; i++) {
linkDropDowns[i].addEventListener("change", function() {
linkButtons[i].href = linkDropDowns[i].value;
});
}