[英]Javascript Submit Form not working
Can anyone see why this form is not submitting ? 谁能看到为什么不提交此表格? I have an asp page with a form, the button is outside the form so I need it to submit using javascript. 我有一个带表单的ASP页面,该按钮位于表单外部,因此我需要使用javascript提交。 The alert box does appear but the form will not submit. 确实会出现警报框,但表单不会提交。
<script>
function validatelink255(){
var promptbox = (confirm('Update Despatch Confirmations?')) ;
if (promptbox == true){
document.Despatchform.submit();
} else {
return false;
}
}
</script>
<form action="purchaseorderfile_detaildespatchupdate.asp?orderno=<%=orderno%>&suppliername=<%=address1%>" method="post" name="Despatchform" id="Despatchform">
<input name="<%=lineno%>checkbox" type="checkbox" id="checkbox"
<%if despatchconfirmed = "yes" then%>
checked="checked"
<%end if%>
/>
</form>
<input type="submit" name="button33" id="button33" value="Save Despatch Confirmations" onClick="return validatelink255(this);"/>
I have just tried changing the javascript in the head section to the code below. 我刚刚尝试将头部的javascript更改为以下代码。 I get the hello alert but not hello2. 我收到了hello警报,但没有得到hello2。
<script>
function validatelink255(){
var promptbox = (confirm('Update Despatch Confirmations?')) ;
if (promptbox == true){
alert("hello");
document.forms['Despatchform'].submit();
alert("hello2");
} else{
return false;
}
}
</script>
What i see is that, you are not passing the form for submit, 我看到的是,您没有通过提交表单,
try this 尝试这个
<script>
function validatelink255(form){
var promptbox = (confirm('Update Despatch Confirmations?')) ;
if (promptbox == true){
form.submit();}
else{
return false;}
}
</script>
<form action="purchaseorderfile_detaildespatchupdate.asp?orderno=<%=orderno%>&suppliername=<%=address1%>" method="post" name="Despatchform" id="Despatchform">
<input name="<%=lineno%>checkbox" type="checkbox" id="checkbox"
<%if despatchconfirmed = "yes" then%>
checked="checked"
<%end if%>
/>
</form>
<input type="submit" name="button33" id="button33" value="Save Despatch Confirmations" onClick="return validatelink255(Despatchform);"/>
输入标签多行代码可能有问题。
<input name="<%=lineno%>checkbox" type="checkbox" id="checkbox" <%if despatchconfirmed = "yes" then%> checked="checked" <%end if%>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.