I am having an issue with assigning a value to a textbox, and I keep getting this error. Here is my code:
This is the textbox in question:
<input id="Text1" type="text" runat="server"/>
Here is the dropdown list used in the function:
<select id="title" name="D1" onchange="Select()" >
<option selected="selected"></option>
<option value="1">Pilot</option>
<option value="5">Engineer</option>
</select>
Below is the JavaScript function being executed:
<script type="text/javascript">
function Select() {
var ddl = document.getElementById("title");
var selected = ddl.options[ddl.selectedIndex].value;
document.getElementById("Text1").value = selected;
alert(document.getElementById("Text1").value);
if (selected == "5") {
document.getElementById('divTechnician').style.visibility = "visible";
} else {
document.getElementById('divTechnician').style.visibility = "hidden";
}
}
</script>
The error seems to arise when trying to assign a value to the text box.
document.getElementById("Text1").value = selected;