打开JavaScript时运行document.forms [0] .submit();

时间:2014-11-02 09:03:42

标签: javascript html

onchange="document.forms[0].action = 'policyTypeSelection.do?method=policyTypeSelection'; document.forms[0].submit(); optionCheck(this);">

optionCheck(this);是Java Script:

function optionCheck(frm) {
    var i, len, optionVal, helpDiv, btnStatus,
    selectOptions = document.getElementById("options").submit();

    // loop through the options in case there
    // are multiple selected values
    for (i = 0, len = selectOptions.options.length; i < len; i++) {

        // get the selected option id
        optionVal = selectOptions.options[i].id;

        // find the corresponding help div
        helpDiv = document.getElementById("help");
        Statussecond = document.getElementById("second");
        Statusfirst = document.getElementById("first");

        // move on if we didn't find one
        if (!helpDiv) { continue; }

        // set CSS classes to show/hide help div
        if (selectOptions.options[i].selected) {

            helpDiv.className = "helpTextShow";
            Statussecond.className = "hiddenShow";
            Statusfirst.className = "none";

        }
    }
}

1 个答案:

答案 0 :(得分:0)

document.getElementById(&#34; options&#34;)。submit()应更改为 document.getElementsByTagName(&#34;选项&#34)

在检查之前提交是不合理的。 如果document.forms [0] .submit()提交表单,页面将被重新加载,并且绝不会执行optionCheck(this)。