JavaScript onchange将表单提交到不同的位置

时间:2014-11-05 06:41:59

标签: javascript html

我似乎无法使用onchange事件。警报触发但我需要提交表单。

<script>
    function validatelink3(returnpartid){
        alert("test");
        var theform = document.partsform;
        theform.action="process_quickedited.asp?returnpartid="+returnpartid;
    }
</script>

<form id="partsform" name="partsform" method="post" action="process_quickedited.asp?returnpartid=undefined">

    <select name="STOCKACTION<%=objRst.fields("returnpartid")%>" id="STOCKACTION<%=objRst.fields    ("returnpartid")%>" onchange="validatelink3(<%=objRst.fields("returnpartid")%>)">
        <option value="<%response.write objRst.fields("stockaction")%>" selected="selected"><%response.write objRst.fields("stockaction")%></option>
        <option value="Return To Supplier">Return To Supplier</option>
        <option value="Stock">Stock</option>
        <option value="Scrap">Scrap</option>
        <option value="Quarantine">Quarantine</option>
        <option value="Test">Test</option>
    </select>

1 个答案:

答案 0 :(得分:1)

如果您希望validatelink3()提交表单,可以使用HTMLFormElement.submit方法:

function validatelink3(returnpartid){
    alert("test");
    var theform = document.partsform;
    theform.action="process_quickedited.asp?returnpartid="+returnpartid;
    theform.submit();
}