This article gives an example of how JavaScript implements the automatic filling out form. Share to everyone for your reference, specific as follows:
In peacetime development process, or visit some sites, often to fill a large pile of forms, we can use JavaScript, write a script, in advance to fill in the information ready, and then simulate the Click button action, automatic submission of forms, easy and efficient.
Steps
1. Locate the corresponding form in the page and list the HTML controls you want in the form, such as
<form name= "Customersform" id= "MyForm" method= "POST" action= "insert.php" >
<b> Last Name: </b> <input Type= "text" name= "Thisfnamefield" size= "value=" ">
<b> Name: </b> <input type=" text "Name=" Thislnamefield "size=" "value=" ">
<b> Company: </b> <input type=" text "name=" Thiscompanyfield "size = "Value=" ">
<b> Address: </b> <input type=" text "name=" Thisaddressfield "size=" value= "" >< C5/></form>
2. Write JS code
Copy Code code as follows:
Javascript:customersForm.thisFnameField.value = "Zhang"; customersForm.thisLnameField.value = "three"; CustomersForm.thisCompanyField.value = "Company"; customersForm.thisAddressField.value = "China"; customersForm.submit.focus ();
3. The third step is the most important, because the first 2 steps a little bit of JS knowledge people will write such a simple code. The next step is to use the browser's Favorites (bookmarks) function to register the JS code.
Take Chrome as an example, right-click on the bookmark ———— > Add page, Name fill in "Automatic fill in", url fill "above that section JS code", and then save.
4. Test it.
Open the page in the browser and click "Auto Fill" in the Bookmarks bar, and you'll be surprised to find that the form has been filled in.
I hope this article will help you with JavaScript programming.