Home > Web Front-end > JS Tutorial > body text

jQuery form filling example sharing

小云云
Release: 2017-12-30 14:47:43
Original
1289 people have browsed it

This article mainly brings you an example of form filling based on jQuery. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.

is as follows:


##

//表单填充
  , formDataLoad: function (domId, obj) {
   for (var property in obj) {
    if (obj.hasOwnProperty(property) == true) {
     if ($("#" + domId + " [name='" + property + "']").size() > 0) {
      $("#" + domId + " [name='" + property + "']").each(function () {
       var dom = this;
       if ($(dom).attr("type") == "radio") {
        $(dom).filter("[value='" + obj[property] + "']").attr("checked", true);
       }
       if ($(dom).attr("type") == "checkbox") {
        obj[property] == true ? $(dom).attr("checked", "checked") : $(dom).attr("checked", "checked").removeAttr("checked");
       }
       if ($(dom).attr("type") == "text" || $(dom).prop("tagName") == "SELECT" || $(dom).attr("type") == "hidden" || $(dom).attr("type") == "textarea") {
        $(dom).val(obj[property]);
       }
       if ($(dom).prop("tagName") == "TEXTAREA") {
        $(dom).val(obj[property]);
       }
      });
     }
    }
   }
  }
Copy after login

Related recommendations:


Detailed example of jQuery form object attribute filter selector

Detailed example of jQuery completing form validation function

Detailed example of jQuery prohibiting form user name , Password autofill function

The above is the detailed content of jQuery form filling example sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template