<%@ 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 />&nbsp&nbsp
<% }%>
<% 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 />&nbsp&nbsp&nbsp&nbsp
<% 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 />&nbsp&nbsp
<br />&nbsp&nbsp
<% } %>
<% }%>
<br />
<br />
<% } %>
<input type="submit" value="保存" class="button" style="margin-left:50px"/>
</form>
<V5:bottom ID="bottom" runat="server" />
</body>
</html>

jquey复选框三级分类关联一二级分类的更多相关文章

  1. Qt树形控件QTreeView使用1——节点的添加删除操作 复选框的设置

    QtreeView是ui中最常用的控件,Qt中QTreeWidget比QTreeView更简单,但没有QTreeView那么灵活(QTreeWidget封装的和MFC的CTreeCtrl很类似,没有m ...

  2. DevExpress XtraGrid RepositoryItemCheckEdit 复选框多选的解决方法

    1. RepositoryItemCheckEdit默认有三种状态,选中状态.未选中状态和半选中状态(半选中状态通常用在TreeList中如果父节点下的子节点有选中的有未选中的,则父节点状态为半选中状 ...

  3. 原生js实现三级复选框

    工作中要做一个三级的复选框,用js实现了一下,从项目中把相关代码抽取出来了,有相关需求的可以参考一下.亲测可用. <!DOCTYPE html> <html> <head ...

  4. vue基于element-ui的三级CheckBox复选框

    最近vue项目需要用到三级CheckBox复选框,需要实现全选反选不确定三种状态.但是element-ui table只支持多选行,并不能支持三级及以上的多选,所以写了这篇技术博文供以后学习使用. 效 ...

  5. MVC树控件,mvc中应用treeview,实现复选框树的多层级表单控件

    类似于多层级的角色与权限控制功能,用MVC实现MVC树控件,mvc中应用treeview,实现复选框树的多层级表单控件.最近我们的项目中需要用到树型菜单,以前使用WebForm时,树型菜单有微软提供的 ...

  6. jquery复选框 选中事件 及其判断是否被选中

    jquery复选框 选中事件 及其判断是否被选中 (2014-07-25 14:03:54) 转载▼ 标签: jquery复选框选中事件 分类: extjs jquery   今天做了 显示和不显示密 ...

  7. jquery 使用attr() 函数对复选框无效的原因,javascript那些事儿——properties和attributes

    复选框是网站开发的时候经常用到的网页标签之一,常见的在页面上对复选框的操作包括取值和修改复选框的状态.在jquery中,常见的操作标签的值得函数为attr,然而在操作复选框的时候,通常采用的却是pro ...

  8. Qt之QHeaderView添加复选框

    简述 前面分享了QTableView中如何添加复选框.本节主要介绍QTableView中的表头-QHeaderView添加复选框的功能,下面以水平表头为例,垂直表头类似! 简述 效果 QHeaderV ...

  9. ListBox复选框拓展

    Toolkit的LongListMutiSelector的复选框功能,想必许多人都需要吧!然而系统本身控件ListBox虽然也有多选功能,可是外观上却缺乏复选框,选择效果只是颜色变化.于是在上一个项目 ...

随机推荐

  1. Java编译原理

    http://wenku.baidu.com/view/f9b1734b87c24028915fc3a3.html Java编译原理 1. 关于动态加载机制 学习Java比C++更容易理解OOP的思想 ...

  2. Delphi 总结操作Excel

    定义变量 Excelid:variant; 1.创建OLE对象 try Excelid:=CreateOleObject( 'Excel.Application' ); except on Excep ...

  3. 进了ACM之后,我才清楚了自己的方向!!!

    2015年8月29日,从郴州比完赛后,状况并没有想象中的乐观,我被卡在了一个数学题上,本来以为这个题目真的是很容易,天真的以为打表就可以敲的出来,可是并没有,横在了一个结束条件上面,比完赛后真想抽自己 ...

  4. 数学概念——G 最大公约数

    G - 数论,最大公约数 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

  5. 什么是Socket,为什么要用Socket

    应用层通过传输层进行数据通信时,TCP和UDP会遇到同时为多个应用程序进程提供并发服务的问题.多个TCP连接或多个应用程序进程可能需要通过同一个TCP协议端口传输数据.为了区别不同的应用程序进程和连接 ...

  6. vijos P1243 生产产品(单调队列+DP)

      P1243生产产品   描述 在经过一段时间的经营后,dd_engi的OI商店不满足于从别的供货商那里购买产 品放上货架,而要开始自己生产产品了!产品的生产需要M个步骤,每一个步骤都可以在N台机器 ...

  7. MyBatis总结-实现关联表查询

    一.一对一关联 1.1.提出需求 根据班级id查询班级信息(带老师的信息) 1.2.创建表和数据 创建一张教师表和班级表,这里我们假设一个老师只负责教一个班,那么老师和班级之间的关系就是一种一对一的关 ...

  8. .net自定义控件

    一.[.net自定义控件]TextBox控件重写 之NumTextBox 参考博客:http://www.yongfa365.com/Item/NumTextBox.html 二.[.net自定义控件 ...

  9. [PWA] 12. Intro to IndexedDB

    Use the library indexedDB-promised. Create a database and stroe: import idb from 'idb'; // Open(db_n ...

  10. [PWA] 0. Introduce to Offline First

    Why offline first? Imagin you are visiting a website, it is fine if wifi connection is good. It migh ...