The analysis of the implementation method of JQuery Select Auto-selecting function _jquery

Source: Internet
Author: User
Tags eval

In this paper, we analyze the implementation method of jquery Select Automatic selection function. Share to everyone for your reference, specific as follows:

Filter
var typeid = "<!--{$typeid}-->";
var bigclassid = "<!--{$bigclassid}-->";
var smallclassid = "<!--{$smallclassid}-->";
$ ("#typeid option[value=" +typeid+ "]"). attr ("selected", true);
$ ("#typeid"). Change ();
$ ("#bigclassid option[value=" +bigclassid+ "]"). attr ("selected", true);
$ ("#bigclassid"). Change ();
$ ("#smallclassid option[value=" +smallclassid+ "]"). attr ("selected", true);

When you get a value, the setting is automatically selected.

When selected, calls the change () method. The Change method displays the next level of the Select box. Then select, and then call the change () method. This shows the three-level select box and is selected by default.

$ (document). Ready (function () {//ajax level $ ("#typeid"). Change (function () {var id = $ (this). Val ();
  Setbigclass (ID);
  });
    $ ("#bigclassid"). Change (function () {var id = $ (this). Val ();
  Setsmallclass (ID);
  });
  $ ("#screen_submit"). Click (function () {$ ("#screenform"). Submit ();
});
});
    function Setbigclass (ID) {var res = Ajaxgetbigclass (ID);
      if (res) {myobj = eval (res);
      var strhtml= "<option value=0> all major categories </option>"; for (Var i=0;i<myobj.length;i++) {strhtml+= "<option value=" "+myobj[i].id+" ' > "+myobj[i].name+" </option
      > ";
      $ ("#bigclassid"). HTML (strhtml);
    $ ("#bigclassid"). Show (). change ();
      }else{$ ("#bigclassid"). html (' <option value= ' "></option> '). Hide ();
    $ ("#smallclassid"). html (' <option value= ' "></option> '). Hide ();
    } function Setsmallclass (ID) {var res = Ajaxgetsmallclass (ID);
      if (res) {myobj = eval (res); var strhtml= "<optionvalue=0> all subcategories </option> "; for (Var i=0;i<myobj.length;i++) {strhtml+= "<option value=" "+myobj[i].id+" ' > "+myobj[i].name+" </option
      > ";
      $ ("#smallclassid"). HTML (strhtml);
    $ ("#smallclassid"). Show ();
  }else{$ ("#smallclassid"). html ('). Hide ();

 }
}

More interested readers of jquery-related content can view the site topics: "jquery form (form) Operation Tips Summary", "jquery common Plug-ins and Usage summary", "JQuery Extended Skills Summary", "jquery switching effects and techniques summary", " jquery traversal algorithm and techniques summary, "jquery Common Classic Effects Summary", "jquery animation and special effects usage Summary" and "jquery Selector usage Summary"

I hope this article will help you with the jquery program design.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.