hide/show field using checkbox/checkboxlist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aboon
    New Member
    • Aug 2008
    • 12

    hide/show field using checkbox/checkboxlist

    Hi I need help with showing field when checkbox checked and hiding field when the checkbox is unchecked.
    I was able to do it using dropdownlist but I'm not able to do it with checkboxlist at all. Would you also explain the differences between dropdownlist and checkboxlist. Thanks
    This is my code using dropdownlist:
    Code:
    <script language="Javascript" type="text/javascript">
    $(document).ready(function(){
         $("select[@ClientSelector=internetResource]").change(function(){
            show_div_by_class_select(this, "Other", "hidable_other");
        });
        
        show_div_by_class_select($("select[@ClientSelector=internetResource]")[0], "Other", "hidable_other");
    });
    </script>
    <fieldset>
        <legend>Additional Forms</legend>
          <asp:DropDownList ID="ddlInternetResource" runat="server" CssClass="singleColInput" ClientSelector="internetResource">
                <asp:ListItem Value="1">Other</asp:ListItem>
                <asp:ListItem Value="2">Shift 2</asp:ListItem>
                <asp:ListItem Value="3">Shift 3</asp:ListItem>
        </asp:DropDownList>
    </fieldset>
    <div class="hidable_other" style="display: none;">
     <p>Signature already aquired.  You may resign if you desire.</p></div>
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You seem to be using jQuery. Anyway, for a checkbox, you can use onclick (click()) or change(), but test the checked property of the checkbox.

    Comment

    Working...