Home >Web Front-end >JS Tutorial >A brief analysis of examples of automatically filling in forms using javascript_javascript skills

A brief analysis of examples of automatically filling in forms using javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:28:173293browse

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

Copy code The code is as follows:
javascript:customersForm.thisFnameField.value = "Zhang";customersForm.thisLnameField.value = "三";customersForm.thisCompanyField.value = "Company";customersForm.thisAddressField.value = "China";customersForm.submit.focus();

3. The third step is the most important, because anyone with a little knowledge of JS in the first two steps will write such a simple code. The next step is to use the browser's favorites (bookmarks) function to store the 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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn