By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

hide/show field using checkbox/checkboxlist

P: 12
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:
Expand|Select|Wrap|Line Numbers
  1. <script language="Javascript" type="text/javascript">
  2. $(document).ready(function(){
  3.      $("select[@ClientSelector=internetResource]").change(function(){
  4.         show_div_by_class_select(this, "Other", "hidable_other");
  5.     });
  7.     show_div_by_class_select($("select[@ClientSelector=internetResource]")[0], "Other", "hidable_other");
  8. });
  9. </script>
  10. <fieldset>
  11.     <legend>Additional Forms</legend>
  12.       <asp:DropDownList ID="ddlInternetResource" runat="server" CssClass="singleColInput" ClientSelector="internetResource">
  13.             <asp:ListItem Value="1">Other</asp:ListItem>
  14.             <asp:ListItem Value="2">Shift 2</asp:ListItem>
  15.             <asp:ListItem Value="3">Shift 3</asp:ListItem>
  16.     </asp:DropDownList>
  17. </fieldset>
  18. <div class="hidable_other" style="display: none;">
  19.  <p>Signature already aquired.  You may resign if you desire.</p></div>
Feb 24 '09 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 16,027
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.
Feb 25 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.