"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Monday, October 10, 2011

Conditionally enabling and disabling dropdown using jquery

Hi *.*,
2day i'm showing enable/disable dropdownlist through checkbox selection using Jquery 
Code

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>DEMO BY SIMPLYASP.BLOGSPOT.COM</title>
    <script src="Script/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#chkbox").click(function () {
                if (this.checked)
                    $('#DrpList').attr('disabled', 'disabled');
                else
                    $('#DrpList').removeAttr('disabled');
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="chkbox" runat="server" Text="Enable/Disable" /><br />
        <asp:DropDownList ID="DrpList" runat="server">
            <asp:ListItem Text="Select" Value="-1"></asp:ListItem>
            <asp:ListItem Text="Option1" Value="1" />
            <asp:ListItem Text="Option2" Value="2" />
            <asp:ListItem Text="Option3" Value="3" />
        </asp:DropDownList>
    </div>
    </form>
</body>
</html>





If u had any trouble just ask, Happy to help u :)
Stay Tune... 
Have a nice day... 'N happy Coding :)

No comments: