so I am working on a project and I need to take the value of a select menu. However, when I do, I get the error TypeError: Cannot read property 'options' of null. Hopefully you guys can help? Here is my HTML code for the select menu:
<div id="MetalTypeSect">
<h2><a id="MetalType"></a>Metal Type</h2>
<select id="select1">
<option value="blank">--Select--</option>
<option value="Alum">Alum. 5052</option>
<option value="GalvL">Galvaneal</option>
<option value="CRS">CRS</option>
<option value="SST">SST304</option>
<option value="GalvZ">Galvanized</option>
</select>
</div>
and here is my js code
var metalTypeSelectedValue = document.getElementById("select1");
var metalType =
metalTypeSelectedValue.options[metalTypeSelectedValue.selectedIndex].value;
while(true) {
if(metalType == "blank") {
document.getElementById("AlumThickness").style.visibility="hidden";
}
}
The error says its on line 2 of the js code. Help!