我想爲什麼我的textarea的值在用戶從下拉菜單中選擇時沒有更新?我使用條件字符串值不正確?當onchange事件發生在select選項上時,textarea值不會更新
這是我想要發生的事情;用戶選擇Filer Changes選項我想用默認值填充textarea,和/或允許用戶更新值,並將其發佈到php頁面。
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<script type="text/javascript"><!--
function updateDescImpact() {
var changeSel = document.changeform.changeType;
var changeType = parseInt(changeSel.options[changeSel.selectedIndex].value);
if(changeType == "Filer Changes") {
document.changeform.description.value = "This is the Filer Change Description";
document.changeform.impact.value = "This is the Filer Changes impact statement";
} else if(changeType == "DNS Changes") {
document.changeform.description.value = "This is the DNS Change Description";
document.changeform.impact.value = "This is the DNS Changes impact statement";
} else {
document.changeform.description.value = "";
document.changeform.impact.value = "";
}
}
// -->
</script>
</head>
<body>
<form name="changeform" method="post" action="">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="18%">Change Type</td>
<td width="82%"><select name="ChangeType" id="ChangeType" onchange="updateDescImpact()">
<option value="Filer Changes">Filer Changes</option>
<option value="DNS Changes">DNS Changes</option>
</select></td>
</tr>
<tr>
<td>Description</td>
<td>
<textarea name="description" id="description" cols="50" rows="10"> This needs to be updated</textarea></td>
</tr>
<tr>
<td>Impact</td>
<td>
<textarea name="impact" id="impact" cols="50" rows="10">This needs to be updated</textarea>
</td>
</tr>
</table>
</form>
</body>
</html>
我覺得這是個問題,'parseInt函數( '文件管理器更改')''給NaN',這不等於什麼。 – RobG
非常感謝穆薩和本傑明的主要問題是我試圖解析changeSel值作爲一個整數。 –
很高興幫助!如果您會如此友善,請選擇一個答案並關閉該問題? – BenJamin