How to hide and show item if checkbox is checked

ImmegeClogS

New Member
I am trying to hide and show an area based on whether a checkbox is checked. I've tried some options but either the area is visible all of the time or it is hidden all of the time.JavaScript :\[code\]$(document).ready(function () { var mgift = $('#chkbxMGift input[type=checkbox]'); MshowHide(); mgift.change(function () { MshowHide(); });});function MshowHide() { var mgift = $('#chkbxMGift input[type=checkbox]'); var shcompany = $('#shcompany'); if (mgift.checked) { shcompany.show(); } else { shcompany.hide(); }}\[/code\]HTML :\[code\]<li> <div class="info"> <asp:CheckBox ID="chkbxMGift" runat="server" Text="A matching gift will be made" ClientIDMode="Static"/> </div></li><li id="shcompany"> <div class="info"> <label for="txtCompanyName">Company Name</label> <asp:TextBox runat="server" ID="txtCompanyName" CssClass="narrow" /> </div> <div class="info"> <label for="txtCompanyPhone">Company Phone Number</label> <asp:TextBox runat="server" ID="txtCompanyPhone" CssClass="narrow" /> </div></li> \[/code\]How can I make this work correctly?
 
Back
Top