2014-11-05 43 views
-2

我似乎無法得到這個與onchange事件一起工作。警報觸發器,但我需要提交表單。JavaScript 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> 
+0

你想要做什麼? – Amy 2014-11-05 06:53:35

+0

使用window.location代替 – Amy 2014-11-05 06:56:32

+0

嗨艾米,我想提交一個表單稱爲partsform到位置=「process_quickedited.asp?returnpartid =」+ returnpartid; - 我不認爲我可以使用window.location,因爲這不會提交表單? – Emma 2014-11-05 07:01:28

回答

1

如果你想validatelink3()提交表單,您可以使用HTMLFormElement.submit方法:

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

Perffect,謝謝。我幾乎在那裏,已經嘗試了form.submit,但沒有支架不起作用。這工作完美。 – Emma 2014-11-05 08:00:58