我有一个jsp,其中一些单选按钮和文本框取决于下拉选择。
这是我的jsp和javascript代码。
jsp
<s:form action="crInquiry" name="form">
<s:select name="filterValue" list="headerList"
onchange="OnChange(this.form.filterValue);" />
<s:radio name="filter" list="#{'STATUS_FILTER_START':'START','STATUS_FILTER_END':'STOP'}"
label="Stage"></s:radio>
<s:textfield disabled="true" value="0" name="count" theme="css_xhtml"></s:textfield>
<s:radio name="ascOrder" list="#{'ASC':'ASC','DESC':'DESC'}"></s:radio>
<s:submit value="Filter" onclick="gotopage('FilteredInquiryLog')"></s:submit>
<s:submitvalue="Details" onclick="gotopage('crInquiry')"></s:submit>
</s:form>
javascript
<script type="text/javascript">
function OnChange(dropdown) {
var myindex = dropdown.selectedIndex;
document.form.filter[0].disabled = false;
document.form.filter[1].disabled = false;
if (myindex == 8) {
alert("8");
document.form.filter[0].disabled = true;
document.form.filter[1].disabled = true;
document.form.count.disabled = false;
document.form.submit.disabled = false;
}
else if (myindex == 9) {
alert("9");
document.form.filter[0].disabled = true;
document.form.filter[1].disabled = true;
document.form.count.disabled = true;
document.form.submit.disabled = false;
}
else{
document.form.filter[0].disabled = false;
document.form.filter[1].disabled = false;
document.form.count.disabled = true;
document.form.submit.disabled = false;
}
}
function gotopage(actionname)
{
document.form.action=actionname+".action";
document.form.submit();
}
</script>
问题是当我在下拉列表中选择一个项目时说元素号。8 或 9 所以通过 javascript 单选按钮应该被禁用 9 的文本字段和单选按钮。当我选择一个项目时,它完全禁用了依赖单选按钮或文本字段但是当我提交时,它显示我启用了单选按钮,因为我来了同一个jsp。我的javascript有什么问题?