The example in this article describes how to automatically fill in the form using JavaScript. Share it with everyone for your reference, the details are as follows:
In the normal development process, or when visiting certain sites, we often need to fill in a lot of forms frequently. We can use javascript to write a script to prepare the information to be filled in in advance, and then simulate clicking the button. Actions to automatically submit forms easily and efficiently.
Steps
1. Find the corresponding form on the page and list the HTML controls required in the form, such as
<form name="customersForm" id="myform" method="POST" action="insert.php"> <b> 姓 : </b> <input type="text" name="thisFnameField" size="20" value=""> <b> 名 : </b> <input type="text" name="thisLnameField" size="20" value=""> <b> 公司 : </b> <input type="text" name="thisCompanyField" size="20" value=""> <b> 地址 : </b> <input type="text" name="thisAddressField" size="20" value=""> </form>
2. Write js code
Take chrome as an example, right-click on the bookmark————> Add a web page, fill in the name [auto-fill form], fill in the URL [the above js code], and then save it.
4. Test it.
Open the corresponding page in the browser, and then click [Autofill] in the bookmark bar. You will be surprised to find that the form has been filled out.
I hope this article will be helpful to everyone in JavaScript programming.