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虽然也有多选功能,可是外观上却缺乏复选框,选择效果只是颜色变化.于是在上一个项目 ...
随机推荐
- 【转】爱普生打印机L358
原文网址:http://www.chiphell.com/thread-838403-1-1.html 儿子幼儿园老是要打印作业,就决定用他的压岁钱买个打印机,主要以文件打印为主,兼顾照片.昨天网上一 ...
- 数学(矩阵乘法):HDU 4565 So Easy!
So Easy! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- Android 屏幕截图
1.同时按下电源键+音量下键截屏 PhoneWindowManager.java private void interceptScreenshotChord() { if (mScreenshotCh ...
- 浅谈二维RMQ
针对一些二维区间最值问题,用一维RMQ来解决显然是不够的.所以,要改进算法.鉴于网上没有PASCAL版的RMQ标程与解析,所以小可在这里简单的讲一下. 核心思想和一维的一样,只是在计算区间时略有不同. ...
- SSL证书的分类(按功能)
SSL证书的分类(按功能) 一.域名型证书 DV SSL DV SSL 证书是 Domain Validation SSL Certificate 英文全称的简写,翻译成中文是域名型 SSL证书 或 ...
- pl sql developer登陆界面找不到oracle数据库选项
window 64位的操作系统 装的数据库win64_11gR2的数据库,PL SQL是PLSQL Developer 7.1.5最后是下载了一个instantclient_11_2包将你数据库安装路 ...
- Android_硬编码设置TextView字体大小
使用如下代码时,发现字号不会变大,反而会变小:size = (int) mText.getTextSize() + 1;mText.setTextSize(size);后来发现getTextSize返 ...
- TCP/IP协议原理与应用笔记11:TCP/IP中地址与层次关系
1. 网络中常用的地址: 2. TCP/IP中地址与层次关系 :
- python----------反射和设计模式
反射: 把字符串映动态射成对象内存地址. hasattr():判断一个对象里是否有对应的字符串的方法 getattr():根据字符串去获取obj对象里的对应方法的内存地址. class Dog(obj ...
- Windows Azure上的Odoo(OpenERP)
OpenERP 改名为 Odoo 了,感觉名字怪怪的.Windows Azure也进入国内了,学习了一段时间的Azure,把它门结合在一起搞搞吧!本系列文章不涉及开发,纯属环境搭建及Odoo 系统功能 ...