Html: Tricks: How to Automate submitting forms

Source: Internet
Author: User
Tags setinterval
Html: Tricks: How to Automate submitting forms
Method One:
<title>untitled document</title>
(1) Automatic submission of the form:
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<script language=javascript>
SetTimeout ("Document.form1.submit ()", 10000)
</script>
<body bgcolor= "#FFFFFF" text= "#000000" >
<form name= "Form1" method= "Post" action= "pp.asp" >
<p>
<input type= "text" name= "TextField" >
</p>
<p>
<input type= "text" name= "Textfield2" >
</p>
</form>
</body>
10 seconds to submit.
---------------------------------------------------------------------------------------------------------
Method Two:
I want to open a page a.htm when the form of a form to the server b.htm submit data, as if to apply for 100 mailboxes, you can achieve it.
---------------------------------------------------------------------------------------------------------

<form name= "Form1" >
</form>
<script>
SetInterval ("Document.all.form1.submit ()", 5000)
</script>

5 seconds at a time.
---------------------------------------------------------------------------------------------------------

1.xmlhttp
2.<form action= "" Name=frm1 Target=_blank method=post>
</form>
<script>
SetTimeout ("Frm1.submit ();", 3000);
</script>
---------------------------------------------------------------------------------------------------------

Using Window.setinterval and window.clearinterval operations, such as the following script is implemented:
<script language= "Javascript" >
var formobj=document.forms["FormName"];
var sobj;

Set the maximum number of automatic commits
var max=100;

Form Submit function
function SubmitForm ()
{
if (formobj&&max>0)
{
formobj.action= "b.htm"//submitted to the page
Formobj.target= "_blank";//Submit with new window
Formobj.submit ()//Execute Commit
max--;
}
Else
Submitint ();
}

Interrupt Auto-Submit function
function Submitint ()
{
if (sobj)
{
Window.clearinterval (Sobj);
max=100;
}
}

Start Auto Submit function
function Submitstart ()
{
Set submit form once per second
Sobj=window.setinterval ("SubmitForm ()", 1000);
}
</script>
You can set up two buttons on the page to perform Submitstart () Start, Submitint () to terminate. where "FormName" is single-name for the table to be submitted. Also note that the script is placed behind the form.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.