Multi-choice box multi-level linkage plug-in implemented by jQuery _ jquery

Source: Internet
Author: User
This article mainly introduces the multi-choice box linkage plug-in implemented by jQuery. If you need it, you can refer to the multi-choice box linkage plug-in implemented by jQuery.

The Code is as follows:


// Use: $ (_ event_src _). autoSelect (_ reload _, reload_url );
// Use the get Method for transmission at the front endLabel attribute "name" and selectedAttribute "value"// Transmit data in json format in the background// Format: {value:"Value", text:Displayed text}(Function ($ ){$. Fn. extend ({AutoSelect: function (dest, url ){Return this. each (function (){$. SelectChange ($ (this), $ (dest), url );});},});// Reset the check box$. SelectReset = function (target ){If (target! = Null ){$. SelectReset (target. data ("nextSelect "));Target. empty ();Target. append (target. data ("defaultOpt "));}};// Load the check box$. SelectLoad = function (target, data ){$. Each (data, function (index, content ){Var option = $ (""). Attr ("value", content. value). text (content. text );Target. append (option );});};// Bind the change event$. SelectChange = function (target, dest, url ){// Bind the linkage chainTarget. data ("nextSelect", dest );// Record default option (first option)If (target. data ("defaultOpt") = null)Target. data ("defaultOpt", target. children (). first ());Dest. data ("defaultOpt", dest. children (). first ());$ (Document). ready (function (){Target. change (function (event ){Var _ target = event.tar get | window. event. srcElement;If (_ target. value! = Target. data ("defaultOpt"). attr ("value ")){$. GetJSON (url ,{"Name": _ target. name,"Value": _ target. value}, Function (data, status ){If (status = "success "){$. SelectReset (target. data ("nextSelect "));$. SelectLoad (target. data ("nextSelect"), data );}}); // The background transmits data in json format} Else {$. SelectReset (target. data ("nextSelect "));}});});};}) (JQuery );

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.