【求各位老师帮我解决个小问题】:多个form怎样按顺序自动提交???
我有个小问题,请各位老师帮个忙。
我想做一个htm网页,里面有3个form,我希望他们按顺序自动提交,即:
页内多个表单自动提交
第2个和第1个间隔5秒,依次类推。。。
每个表单只提交一次,避免重复
请问,用什么js代码能实现这个效果?
有劳各位~~~~~谢谢了~
礼!
------解决方案-------------------- <script language=javascript defer> //至于每隔几秒,写setTimeout就可以了
form1.submit()
form2.submit()
form3.submit()
</script>
<form name= "form1 " target= "iframe1 ">
</form>
<form name= "form2 " target= "iframe1 ">
</form>
<form name= "form3 " target= "iframe1 ">
</form>
<iframe name= "iframe1 "> </iframe>
------解决方案-----------------------------------1.htm 代码-------
<HTML>
<HEAD>
<TITLE> 多个form怎样按顺序自动提交 </TITLE>
</HEAD>
<BODY>
<IFRAME NAME= "iframe1 " SRC= "2.htm?0 "> </IFRAME>
<FORM NAME= "form1 " TARGET= "iframe1 " METHOD= "POST " ACTION= "2.htm?1 "> 1 </FORM>
<FORM NAME= "form2 " TARGET= "iframe1 " METHOD= "POST " ACTION= "2.htm?2 "> 2 </FORM>
<FORM NAME= "form3 " TARGET= "iframe1 " METHOD= "POST " ACTION= "2.htm?3 "> 3 </FORM>
<INPUT TYPE= "button " VALUE= "多个表单递交 " ONCLICK= "AutoPost(); ">
<SCRIPT LANGUAGE= "javascript ">
FormsCount = document.forms.length;//表单总数
//alert(FormsCount);
function AutoPost()
{
inter = setInterval( "BePost() ", 5000);//5000毫秒
}
var i=0;
function BePost()
{
document.forms[i].submit();
i++;
if (i> =FormsCount) clearInterval(inter);
}
</SCRIPT>
</BODY>
</HTML>
---------------2.htm 代码---------
<html>
<head>
<title> 接受提交演示 </title>
</head>
<body>
<SCRIPT lanaguage= "javascript ">
var id = parseInt(location.search.substr(1));
document.write(id);
</SCRIPT>
</body>
</html>