Я пытаюсь получить значение раскрывающегося списка и продолжать получать сообщение об ошибке Uncaught TypeError: Не удается прочитать свойство "selectedIndex" из null.
Вот мой код:
JS
expirationYearSelectedIndex = document.getElementById("selYear").selectedIndex;
console.log("expirationYearSelectedIndex = " + expirationYearSelectedIndex);
expirationYear = document.getElementById("selYear").options[expirationYearSelectedIndex].value;
console.log("expirationYear = " + expirationYear);
HTML
<form action="">
<select id="SelYear" name="selYear">
<option selected value=""> Select a Major....</option>
<option value="Comptuer Information Systems"> CIS</option>
<option value="Math"> M</option>
<option value="CS"> CS</option>
<option value="History"> H</option>
</select>
</form>
Пропущенный капитал S по идентификатору <select id="SelYear" name="selYear">
document.getElementById("SelYear");