惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - 丁学

javascript实现可以拖动的层示例(层拖动,兼容IE/FF) 《博客园精华集:Web标准之道》内容提要、序、前言、封面 终于有时间聊聊《Silverlight2 完美征程》 可怜的家居易站,早说过不要乱搞 还是无法忘怀——三鹿 水土不服的SNS,落地生根的网游 无敌博皮 之 乾坤大变色——支持:后续更新 无敌博皮 之 乾坤大变色——下篇:脚本讲解 无敌博皮 之 乾坤大变色——中篇:样式说明 无敌博皮 之 乾坤大变色——上篇:使用方法 原来,程序的世界远比我想象的精彩 拿到微软GDI(最有影响力开发者)礼包 对“关于购物车的想法”的一些回复 SEO--我们是不是走错了路? 关于参数为可空值类型的多个重载的优先级 (彻底晕掉了) 电子商务胡说八道之:淘宝封百度,卖家很受伤 测试搜索引擎收录状态(2008-09),顺便测试一下CSDN那帮超有才的编辑 测试一下找找看 TerryLee [当当网,你意欲何为]之三:不解,那可怜的UE
如何实现在客户端,使CheckBox按照选择的顺序进行排序--来自博问的问题
丁学 · 2008-10-19 · via 博客园 - 丁学

原问题:如何实现在客户端,使CheckBox按照选择的顺序进行排序

在客户端,对CheckBox按照选择的顺序进行排序。
选择多CheckBox后,如果取消其中一个CheckBox(A),则
则序号比CheckBox(A)大的均要减1,
希望的效果如下:
丁学是个好人,哈哈哈哈

解决代码如下:(checkbox与对应的textbox要拥有相似的名字,如ckbAAA必须对应txtAAA,不然要绕圈通过parent取,懒得作,先这样)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
    <title>丁学-博问demo</title>
</head>
<body>
    <form id="form1" runat="server">
    <table id="tableSn">
        <tr>
            <td><asp:CheckBox ID="ckbCarType" runat="server" Text="机型" onclick="chk(this)" /></td>
            <td><asp:TextBox ID="txtCarType" runat="server" Width="20px"></asp:TextBox></td>
            <td><asp:CheckBox ID="ckbGood" runat="server" Text="零件号" onclick="chk(this)" /></td>
            <td style="width: 20px"><asp:TextBox ID="txtGood" runat="server" Width="20px"></asp:TextBox></td>
        </tr>
        <tr>
            <td><asp:CheckBox ID="ckbLine" runat="server" Text="品别" onclick="chk(this)" /></td>
            <td><asp:TextBox ID="txtLine" runat="server" Width="20px"></asp:TextBox></td>
            <td><asp:CheckBox ID="ckbClass" runat="server" Text="班别" onclick="chk(this)" /></td>
            <td style="width: 20px"><asp:TextBox ID="txtClass" runat="server" Width="20px"></asp:TextBox></td>
        </tr>
        <tr>
            <td><asp:CheckBox ID="ckbUnContent" runat="server" Text="不良说明" onclick="chk(this)" /></td>
            <td><asp:TextBox ID="txtUnContent" runat="server" Width="20px"></asp:TextBox></td>
            <td><asp:CheckBox ID="ckbMachine" runat="server" Text="机器号" onclick="chk(this)" /></td>
            <td style="width: 20px"><asp:TextBox ID="txtMachine" runat="server" Width="20px"></asp:TextBox></td>
        </tr>
        <tr>
            <td><asp:CheckBox ID="ckbUnPlace" runat="server" Text="不良点" onclick="chk(this)" /></td>
            <td><asp:TextBox ID="txtUnplace" runat="server" Width="20px"></asp:TextBox></td>
            <td><asp:CheckBox ID="ckbPartItem" runat="server" Text="成品名" onclick="chk(this)" /></td>
            <td style="width: 20px"><asp:TextBox ID="txtPartItem" runat="server" Width="20px"></asp:TextBox></td>
        </tr>
        <tr>
            <td><asp:CheckBox ID="ckbManagePoint" runat="server" Text="部位名" onclick="chk(this)" /></td>
            <td><asp:TextBox ID="txtManagePoint" runat="server" Width="20px"></asp:TextBox></td>
            <td></td>
            <td style="width: 20px"></td>
        </tr>
        <tr>
            <td colspan="2"><asp:CheckBox ID="ckbUnDate" runat="server" Text="发生日" onclick="chk(this)" /></td>
            <td colspan="2">
                <asp:TextBox ID="txtUnDate" runat="server" Width="20px"></asp:TextBox>
                <asp:DropDownList ID="dpdDateSquence" runat="server">
                    <asp:ListItem>按月</asp:ListItem>
                    <asp:ListItem>按日</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td colspan="2"><asp:CheckBox ID="ckbUnReason" runat="server" Text="不合格原因" onclick="chk(this)" /></td>
            <td colspan="2">
                <asp:TextBox ID="txtUnReason" runat="server" Width="20px"></asp:TextBox>
                <asp:DropDownList ID="dpdProject" runat="server"></asp:DropDownList>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        // 丁学, Ding Xue, http://www.cnblogs.com/DingXue
        var checkedIds = "";    //记录被选中的ID们
        function chk(obj){
            if(obj.checked==true)
                checkedIds += obj.id + ",";
            else{
                document.getElementById(obj.id.replace("ckb","txt")).value="";
                checkedIds = checkedIds.replace(obj.id+",","");
            }
            var item = checkedIds.split(',');
            for(var i=0;i<item.length-1;i++)
                document.getElementById(item[i].replace("ckb","txt")).value=i+1;
        }
    </script>
    </form>
</body>
</html>