Home >Web Front-end >JS Tutorial >Use javascript to imitate IE's automatic completion of a form similar to the automatic completion_javascript skills
Use javascript to imitate IE's automatic completion of a form similar to the automatic completion_javascript skills
WBOYOriginal
2016-05-16 17:46:491165browse
I was writing a javascript framework recently, and I saw a lot of forms with auto-complete functions on the Internet, so on a whim, I wrote one in javascript to add some color to my framework.
Steps: 1. Pass in two parameters, the first is the form object you want to bind, and the second is the array you want to retrieve. 2. Dynamically create a div as the layer you want to automatically complete , set attributes and events (I did not set the visible and display attributes of the div here, but set its left to "-1000px", thus moving it out of the browser and achieving a hidden effect. 3. Retrieve the incoming array, find items that match or are similar to the input content, and store them in a new array. Four iterations were performed here using regular expressions. I apologize for the poor writing. . 4. Process the new array where the retrieved data is stored, remove items with duplicate content, and write them into the div. 5. Set the left, top, and width of the div.
The code is not optimized, please bear with me, here is an idea , making everyone laugh.
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