<%
if Request.QueryString("action")="loadsubmit" then
Response.Write("自动提交")
end if
%>
<body>
<form id="form1" name="form1" method="post" action="?action=loadsubmit">
<input name="text1" type="text" value="自动提交" />
</form>
<script>
var i=3;//3秒后自动提交
function load_submit()
{
if(i==0)
{
document.form1.submit();
clearTimeout(load_t);
}
document.form1.text1.value=i+" 秒后提交";
i--;
var load_t=setTimeout("load_submit()",1000);
}
load_submit();
</script>
</body>
扩展资料
1,不断提交表单:
<form name="hiddenForm" action="xxx">
<input type="hidden" name="code" value=<%=code%>>
<input type="hidden" name="informId" value=<%=id%>>
</form>
<script>
document.hiddenForm.submit()
</script>
2,表单只提交一次:
<script>
function submitForm() {
var frm = document.getElementById("hiddenform");
rm.submit();
}
</script>
</head>
<body onload="submitForm();">
<form id="hiddenform"
action="${pageContext.request.contextPath}/informController/countRead.action">
<input type="hidden" name="code" value=<%=code%>>
<input type="hidden" name="informId" value=<%=id%>>
</form>
</body>
参考资料:百度百科 - javascript
2024-07-18 广告
原生javascript代码,:
window.onload= function(){
document.getElementById('myForm').submit();
}
jQuery代码:
$(function(){
$('#myForm').submit();
});
if Request.QueryString("action")="loadsubmit" then
Response.Write("自动提交")
end if
%>
<body>
<form id="form1" name="form1" method="post" action="?action=loadsubmit">
<input name="text1" type="text" value="自动提交" />
</form>
<script>
var i=3;//3秒后自动提交
function load_submit()
{
if(i==0)
{
document.form1.submit();
clearTimeout(load_t);
}
document.form1.text1.value=i+" 秒后提交";
i--;
var load_t=setTimeout("load_submit()",1000);
}
load_submit();
</script>
</body>
{
document.myForm.submit();
}
setTimeout(sub,1000);
</script>
1000为一秒后自动提交
FORM名.submit();
}