javascript';s函数第二次不工作

javascript';s函数第二次不工作,javascript,html,jsp,struts2,Javascript,Html,Jsp,Struts2,我正在使用javascript的以下功能来启用和禁用单选按钮和文本框,因为下拉列表的值发生了变化。启动时没有问题,但当我点击提交按钮时,如果提交时myindex=8或9,则无法工作。 此时,单选按钮filter[0]和filter[1]应该被禁用,textfield count应该被启用。我在选择下拉菜单并单击提交按钮时调用了此功能。我不知道为什么它不工作。任何帮助 function OnChange(dropdown) { var myindex = dropdown.selected

我正在使用javascript的以下
功能来启用和禁用
单选按钮
文本框
,因为
下拉列表的值发生了变化。
启动时没有问题,但当我点击提交按钮时,如果提交时
myindex=8或9
,则无法工作。
此时,
单选按钮filter[0]和filter[1]
应该被禁用,
textfield count
应该被启用。我在选择下拉菜单并单击提交按钮时调用了此功能。
我不知道为什么它不工作。任何帮助

function OnChange(dropdown) {
    var myindex = dropdown.selectedIndex;

    document.form.filter[0].disabled = false;
    document.form.filter[1].disabled = false;

    if (myindex == 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("in ALL");
        document.form.filter[0].disabled = true;
        document.form.filter[1].disabled = true;
        document.form.count.disabled = true;
        document.form.submit.disabled = false;

        alert(document.form.filter[0].disabled);
    }

    else {
        document.form.filter[0].disabled = false;
        document.form.filter[1].disabled = false;
        document.form.count.disabled = true;
        document.form.submit.disabled = false;
    }
}
下面是我的HTML代码

<s:form action="crInquiry" name="form" >
    <table align="center" width="1020">
        <tr>
            <td>Batch Id : <s:property value="batchId" />
                <fieldset
                    style="background-color: #F7F9F3; margin: 2px; padding: 8px; -moz-border-radius: 5pt; border: 1px solid #A7CBE3;">
                    <legend class="field_label">
                        <strong>Inquiry Log Status</strong>
                    </legend>
                    <table border="0" id="main_table1" cellpadding="5" width="1010"
                        cellspacing="5" align="center">
                        <tr style="height: 5px;">
                            <td width="300" height="2" align="left" colspan="0"><s:hidden
                                    name="batchId" id="batchId"
                                    onfocus="OnChange((this.form.filterValue));"
                                    value="%{ batchId }"></s:hidden> <s:select
                                    cssClass="bulkSelect" name="filterValue"
                                    label="Search Criteria" required="true" theme="css_xhtml"
                                    labelposition="bottom" tabindex="2" list="headerList"
                                    onchange="OnChange(this.form.filterValue);" />
                            </td>


                            <td width="180"><s:radio name="filter"
                                    requiredposition="right"
                                    list="#{'STATUS_FILTER_START':'START','STATUS_FILTER_END':'END'}"
                                    label="Stage" labelposition="right" theme="css_xhtml"
                                    tabindex="9" labelposition="bottom"></s:radio>
                            </td>
                            <td width="50" height="2"><s:textfield disabled="true"
                                    value="0" name="count" size="2" labelposition="1"
                                    theme="css_xhtml"></s:textfield>
                            </td>
                            <td width="180"><s:radio name="order"
                                    requiredposition="right" list="#{'ASC':'ASC','DESC':'DESC'}"
                                    label="Order" labelposition="right" theme="css_xhtml"
                                    tabindex="9" labelposition="bottom"></s:radio>
                            </td>
                            </td>


                            <td width="50"><s:submit theme="css_xhtml" value="Filter"
                                    align="left" onclick="gotopage('FilteredInquiryLog');"></s:submit>
                            </td>
                            <td width="59"><s:submit theme="css_xhtml" value="Details"
                                    onclick="gotopage('crInquiry')"></s:submit></td>

                        </tr>


                    </table>
                </fieldset>
            </td>
        </tr>

    </table>
</s:form>

这似乎很奇怪,你会提交表单,然后试图操纵字段

function gotopage(actionname) { 
        document.form.action = actionname + ".action";
        document.form.submit();
        OnChange(document.form.filterValue);

    }
也许你需要的是:

function gotopage(actionname) { 
        OnChange(document.form.filterValue);

        document.form.action = actionname + ".action";
        document.form.submit();
    }

请显示相关的HTML并显示从提交操作调用此函数的代码。@Nivesh:您怎么可能认为这些信息足以让人帮助您?@bernie请原谅,我刚刚添加了相关代码。您真的应该尝试减少代码量以重现此问题。当你有这么多事情要做的时候,很难在几分钟内理解你想做什么。@DmitryB我想你是对的,我将减少代码并将其作为新问题发布。
function gotopage(actionname) { 
        OnChange(document.form.filterValue);

        document.form.action = actionname + ".action";
        document.form.submit();
    }