The jquey check box is associated with level 1 and level 2 categories,

Source: Internet
Author: User

The jquey check box is associated with level 1 and level 2 categories,

<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "Category_Manage_New_Two.aspx.cs" Inherits = "Lilaidao. admin. weblogin. category_Manage_New_Two "%> <% @ Register Src =" bottom. ascx "TagName =" bottom "TagPrefix =" V5 "%> the main code is as follows <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head id =" Head1 "runat =" server "> <title> product category management </title> <link href =" css/css.css "rel =" stylesheet "type = "text/css"/> <link href = "css/css_list.css" rel = "stylesheet" type = "text/css"/> <link href = "css/control.css" rel = "stylesheet" type = "text/css"/> <script language = "javascript" type = "text/javascript" src = "js/Common. js "> </script> <script src =" js/jquery-1.3.2.min.js "type =" text/javascript "> </script> <Script type = "text/javascript"> $ (function () {$ ("input [name = 'category1']"). click (function () {var idvalue = $ (this ). val (); var check = this. checked; var idvalue2; var check2; $ ("input [name = 'category2']"). each (function (index, ele) {if ($ (ele ). attr ("ParentId") = idvalue) {ele. checked = check; idvalue2 = $ (ele ). val (); check2 = ele. checked; $ ("input [name = 'category3']"). each (function (index, ele) {If ($ (ele ). attr ("ParentId") = idvalue2) {ele. checked = check2 ;}}) ;}$ ("input [name = 'category2']"). click (function () {var parentId = $ (this ). attr ("ParentId") // obtain the parent Id var check = this. checked; // The selected status of the secondary category $ ("input [name = 'category1']"). each (function (index, ele) {if ($ (ele ). val () = parentId) {var idvalue = $ (this ). val () // obtain the id of the first-level classification // var countOne =$ ("input [type = 'checkbox'] [par Entid = '"+ idvalue +"'] "). length // obtain the total number of second-level category selection boxes. // obtain the number of second-level categories. If the number is greater than 0, select var count = $ ("input [type = 'checkbox'] [parentid =' "+ idvalue +" ']: checked "). length; count> 0? Ele. checked = true: ele. checked = false ;}}) idvalue2 = $ (this ). val (); // obtain the parent id check2 = this. checked; // The selected status of the secondary category $ ("input [name = 'category3']"). each (function (index, ele) {if ($ (ele ). attr ("ParentId") = idvalue2) {ele. checked = check2 ;}}) ;}); $ ("input [name = 'category3']"). click (function () {var parentId = $ (this ). attr ("ParentId") // obtain the parent Id var check = this. checked; // The selected status of the third-level category $ ("Indium Ut [name = 'category2'] "). each (function (index, ele) {if ($ (ele ). val () = parentId) {var idvalue = $ (this ). val () // obtain the id of the second-level classification // var countOne =one ("input [type = 'checkbox'] [parentid = '" + idvalue + "']"). length // obtain the total number of second-level category selection boxes // obtain the number of three-level category selection. If the number is greater than 0, the second-level category is selected, for the corresponding level-1 category, select var count = $ ("input [type = 'checkbox'] [parentid = '" + idvalue + "']: checked "). length; // count> 0? Ele. checked = true: ele. checked = false; if (count> 0) {ele. checked = true // select the level-2 Classification var id1 = $ (ele ). attr ("ParentId") // obtain the id of the first-level category $ ("input [type = 'checkbox'] [value = '" + id1 + "']"). attr ("checked", "checked"); // select a level-1 category} else {ele. checked = false; // select the level-2 Classification var id1 = $ (ele ). attr ("ParentId") // obtain the id of the first-level category $ ("input [type = 'checkbox'] [value = '" + id1 + "']"). attr ("checked", ""); // do not select a level-1 category }}})});}) </script> 

  

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.