AutoFill. js
(Function (window, document, undefined) {// defines the automatic filling form tool var AutoFill = {// defines the constant _ text: 0, _ password: 1, _ select: of the form Element: 2, _ radio: 3, _ lable: 4, // automatically fill in the Form data [{field: username, value: William, type: text}] _ formdata: [], _ formdatapath: [], _ formdataindexpath: "formdata/index. JS ", _ formdataindex :{}, // initialization method init: function (options) {_ formdatapath = options. formdatapath;}, // fill in the HTML element _ inputdata: function () {var self = This; self. _ formdatapath = self. _ formdataindex [$ (document ). find ('# test0 '). val ()]; $. ajax ({URL: Self. _ formdatapath, type: 'get', success: function (response) {self. _ formdata = eval (response); var Len = self. _ formdata. length; If (LEN = 0) {return} For (VAR I = 0; I <Len; I ++) {var TMP = self. _ formdata [I]; var element = $ (TMP. field); var type = self. _ GetType (element); Switch (type) {Case self. _ text: element. val (TMP. value); break; case self. _ password: element. val (TMP. value); break; case self. _ select: element. val (TMP. value); break; case self. _ radio: break; case self. _ lable: element. text (TMP. value); break ;}}}) ;}, // determines the type of the filled HTML element _ GetType: function (element) {var self = This; var type = element. ATTR ('type'); If (/text /. test (type) {return self. _ text;} If (/password /. test (type) {return self. _ password;} if ($ (element ). is ('select') {return self. _ select;} If (/Radio /. test (type) {return self. _ radio;} if ($ (element ). is ('span ') {return self. _ lable ;}}// listen to the F11 button and execute the form filling function $ (document ). keydown (function (e) {Switch (E. keycode) {Case 122: $. ajax ({URL: AutoFill. _ formdataindexpath, type: 'get', success: function (response) {AutoFill. _ formdataindex = (eval (response) [0]; AutoFill. _ inputdata () ;}}); return false ;}}) (window, document );
Index. js
[{Loginfill: 'formdata/loginfill. js'}] loginfill. js
[{Field: '# loginusername', value: 'test'}, {field: '# loginpassword', value: 'test'}]