我正在尝试设置文本框的值,我收到此错误... 请看我的代码:
这是我的文本框
<input id="Text1" type="text" runat="server"/>
这是我的下拉列表
<select id="title" name="D1" onchange="Select()" >
<option selected="selected"></option>
<option value="1">Pilot</option>
<option value="5">Engineer</option>
</select>
这就是我的功能
<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>
当我尝试为此文本框分配值时发生错误
document.getElementById("Text1").value = selected;
答案 0 :(得分:2)
将clientidmode = static设置为此元素
<input id="Text1" type="text" runat="server" clientIdMode="static"/>