我想知道为什么当用户从下拉菜单中选择时我的 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>