Emma Emma - 6 months ago 44
HTML Question

JavaScript onchange to submit form to different location

I can't seem to get this working with the

onchange
event. The alert triggers but I need the form submitting.

<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>

Answer

If you want validatelink3() to submit the form, you can use the HTMLFormElement.submit method:

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