Return to Snippet

Revision: 26811
at May 11, 2010 14:13 by omixen


Initial Code
<%@ 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>Test jQuery infused cblist</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script type="text/javascript">
        var selectedBox = 0;
        var multiBox = false;
        var lastChecked = null;
        $(document).ready(
            function() {
                $(".multiplus input:checkbox").click(
                    function() {
                        if (!multiBox) {
                            if ($(this).attr("checked")) {
                                $(lastChecked).attr("checked", false).parent().css({ "background-color": "#FFF", "font-weight": "normal" });
                                lastChecked = this;
                            }
                        }
                        if ($(this).attr("checked")) {
                            $(this).parent().css({ "background-color": "#FFC", "font-weight": "bold" });
                            selectedBox++;
                        } else {
                            $(this).parent().css({ "background-color": "#FFF", "font-weight": "normal" });
                            selectedBox--;
                        }
                    }
                );
            }
        );
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="width:200px;height:300px;border:1px solid #999;overflow:scroll;">
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" DataTextField="Title" DataValueField="RowID" DataSourceID="SqlDataSource1" CssClass="multiplus">
        </asp:CheckBoxList>        
    </div>
    </form>
</body>
</html>

Initial URL

                                

Initial Description

                                

Initial Title
multi checkbox list

Initial Tags

                                

Initial Language
HTML