jquey复选框三级分类关联一二级分类
<%@ 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" %>
主要代码如下
<!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>商品分类管理</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") //得到二级分类的父Id
var check = this.checked; //二级分类的选中状态
$("input[name='Category1']").each(function (index, ele) {
if ($(ele).val() == parentId) {
var idvalue = $(this).val() //得到一级分类的id
//var countOne = $("input[type='checkbox'][parentid='" + idvalue + "']").length //得到二级分类选择框总数
//得到二级分类选择的个数如果大于0 一级分类选中
var count = $("input[type='checkbox'][parentid='" + idvalue + "']:checked").length;
count > ? ele.checked = true : ele.checked = false;
} }) idvalue2 = $(this).val(); //得到三级分类的父id
check2 = this.checked; //二级分类的选中状态
$("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") //得到三级分类的父Id
var check = this.checked; //三级分类的选中状态
$("input[name='Category2']").each(function (index, ele) {
if ($(ele).val() == parentId) {
var idvalue = $(this).val() //得到二级分类的id
//var countOne = $("input[type='checkbox'][parentid='" + idvalue + "']").length //得到二级分类选择框总数
//得到三级分类选择的个数如果大于0 二级分类选中 ,对应的一级分类也选中
var count = $("input[type='checkbox'][parentid='" + idvalue + "']:checked").length;
// count > 0 ? ele.checked = true : ele.checked = false;
if (count > ) {
ele.checked = true //选中二级分类
var id1 = $(ele).attr("ParentId") //得到一级分类的id
$("input[type='checkbox'][value='" + id1 + "']").attr("checked", "checked"); //选中一级分类 } else {
ele.checked = false; //选中二级分类
var id1 = $(ele).attr("ParentId") //得到一级分类的id
$("input[type='checkbox'][value='" + id1 + "']").attr("checked", ""); //不选中一级分类
}
} }) }); })
</script>
</head>
<body>
<form id="form1" method="post">
<div class="OperateTitle">
<div>
【 商品分类管理 】
</div>
</div>
<% foreach (var item1 in list1)
{
string checks1 = "";
if (item1.IsMarket==true)
{
checks1 = "checked='checked'";
}
%>
<input type="checkbox" name="Category1"<%=checks1%> id=<%=item1.Id%> value= <%=item1.Id%> parentid="<%=item1.ParentId%>" / >
<label for=<%=item1.Id%>><%=item1.Title %></label> <% var listCate2 = cgbll.GetList(item1.Id, false);
if (listCate2.Count > )
{ %>
<br />  
<% }%>
<% foreach (var item2 in listCate2)
{
string checks2 = "";
if (item1.IsMarket == true)
{
checks2 = "checked='checked'";
}
%>
<input type="checkbox" name="Category2" <%=checks2%> id=<%=item2.Id%> value= <%=item2.Id%> parentid="<%=item2.ParentId%>" / > <label for=<%=item2.Id%>><%=item2.Title %></label>
<% var listCate3 = cgbll.GetList(item2.Id, false);
if (listCate3.Count>)
{%>
<br />    
<% foreach (var item3 in listCate3 )
{
string checks3 = "";
if (item1.IsMarket == true)
{
checks3 = "checked='checked'";
}
%>
<input type="checkbox" name="Category3"<%=checks3%> id=<%=item3.Id%> value= <%=item3.Id%> parentid="<%=item3.ParentId%>" / > <label for=<%=item3.Id%>><%=item3.Title %></label>
<% } %>
<br />  
<br />  
<% } %>
<% }%>
<br />
<br />
<% } %>
<input type="submit" value="保存" class="button" style="margin-left:50px"/>
</form>
<V5:bottom ID="bottom" runat="server" />
</body>
</html>
jquey复选框三级分类关联一二级分类的更多相关文章
- Qt树形控件QTreeView使用1——节点的添加删除操作 复选框的设置
QtreeView是ui中最常用的控件,Qt中QTreeWidget比QTreeView更简单,但没有QTreeView那么灵活(QTreeWidget封装的和MFC的CTreeCtrl很类似,没有m ...
- DevExpress XtraGrid RepositoryItemCheckEdit 复选框多选的解决方法
1. RepositoryItemCheckEdit默认有三种状态,选中状态.未选中状态和半选中状态(半选中状态通常用在TreeList中如果父节点下的子节点有选中的有未选中的,则父节点状态为半选中状 ...
- 原生js实现三级复选框
工作中要做一个三级的复选框,用js实现了一下,从项目中把相关代码抽取出来了,有相关需求的可以参考一下.亲测可用. <!DOCTYPE html> <html> <head ...
- vue基于element-ui的三级CheckBox复选框
最近vue项目需要用到三级CheckBox复选框,需要实现全选反选不确定三种状态.但是element-ui table只支持多选行,并不能支持三级及以上的多选,所以写了这篇技术博文供以后学习使用. 效 ...
- MVC树控件,mvc中应用treeview,实现复选框树的多层级表单控件
类似于多层级的角色与权限控制功能,用MVC实现MVC树控件,mvc中应用treeview,实现复选框树的多层级表单控件.最近我们的项目中需要用到树型菜单,以前使用WebForm时,树型菜单有微软提供的 ...
- jquery复选框 选中事件 及其判断是否被选中
jquery复选框 选中事件 及其判断是否被选中 (2014-07-25 14:03:54) 转载▼ 标签: jquery复选框选中事件 分类: extjs jquery 今天做了 显示和不显示密 ...
- jquery 使用attr() 函数对复选框无效的原因,javascript那些事儿——properties和attributes
复选框是网站开发的时候经常用到的网页标签之一,常见的在页面上对复选框的操作包括取值和修改复选框的状态.在jquery中,常见的操作标签的值得函数为attr,然而在操作复选框的时候,通常采用的却是pro ...
- Qt之QHeaderView添加复选框
简述 前面分享了QTableView中如何添加复选框.本节主要介绍QTableView中的表头-QHeaderView添加复选框的功能,下面以水平表头为例,垂直表头类似! 简述 效果 QHeaderV ...
- ListBox复选框拓展
Toolkit的LongListMutiSelector的复选框功能,想必许多人都需要吧!然而系统本身控件ListBox虽然也有多选功能,可是外观上却缺乏复选框,选择效果只是颜色变化.于是在上一个项目 ...
随机推荐
- POJ-2774-Long Long Message(后缀数组-最长公共子串)
题意: 给定两个字符串 A 和 B,求最长公共子串. 分析: 字符串的任何一个子串都是这个字符串的某个后缀的前缀. 求 A 和 B 的最长公共子串等价于求 A 的后缀和 B 的后缀的最长公共前缀的最大 ...
- 吐槽iOS国际化:关于NSLocalizedString的使用
http://blog.csdn.net/aries4ever/article/details/8185405
- android里Toast的用法
在活动中,可以通过findViewById()方法获取到在布局文件中定义的元素,这里我们传入R.id.button_1,来得到按钮的实例,这个值是刚才在first_layout.xml中通过andro ...
- 谈一下spring 的理解
spring,大家基本都在使用,两个核心: 声明式事务AOP : 控制反转依赖注入IOC: 以前对控制反转和依赖注入很模糊,现在大概理解了意思,控制反转,有spring容易来控制bean 的创建,我们 ...
- cgdb调试postgresql
之前一直用gdb调试代码,最近在搞pg的时候用了一个cgdb,体验很好,调试pg代码的时候真的很方便. 本文主要讲解在进行pg内核开发的时候,如何搭建一个环境,用cgdb方便快捷的调试postgres ...
- Android Touch系统简介(二):实例详解onInterceptTouchEvent与onTouchEvent的调用过程
上一篇文章主要讲述了Android的TouchEvent的分发过程,其中有两个重要的函数:onInterceptTouchEvent和onTouchEvent,这两个函数可被重装以完成特定的逻辑.on ...
- Java使用Protocol Buffers入门四步骤
Protocol Buffers(简称protobuf)是谷歌的一项技术.用于将结构化的数据序列化.反序列化.经经常使用于网络传输. 这货实际上相似于XML生成和解析.但protobuf的效率高于XM ...
- phpcms如何嵌套循环
PHPCMS V9的标签制作以灵活见长,可以自由DIY出个性的数据调用,对于制作有风格有创意的网站模板很好用,今天就介绍一个标签循环嵌套方法,可以实现对PC标签循环调用,代码如下: 在此文件里/php ...
- 汉诺塔III 递推题
题目描述: 约19世纪末,在欧州的商店中出售一种智力玩具,在一块铜板上有三根杆,最左边的杆上自上而下.由小到大顺序串着由64个圆盘构成的塔.目的是将最左边杆上的盘全部移到右边的杆上,条件是一次只能移动 ...
- xUtils3源码分析(一):view的绑定
概述 xUtils3是国人开发的一款功能丰富的Android快速开发框架,值得研究下.zip包下载:[ZIP]xutils主要分以下几个模块 视图绑定模块 网络请求模块 数据库模块 图片加载模块 我们 ...