Garima Bansal

Garima Bansal

  • 1.1k
  • 674
  • 39.2k

show textbox when checkbox is checked

Sep 20 2022 5:28 AM

i am trying to make,when checkbox is checked textbox should be shown but when check box is unchecked text box should be hide.This is how i implement this so far.

            <strong> Examination Required:</strong>
                               <asp:CheckBox ID="chkexamination" runat="server" onclick="ShowHideDiv(this)" />

     <div class="col-md-6" id="chkremarks">
                    <strong>Remarks Examination:</strong>
                    <asp:TextBox runat="server" ID="txtremarksfr" CssClass="form-control"></asp:TextBox>
                    </div>
 </div>

 

 <script type="text/javascript">
        function ShowHideDiv(chkexamination) {
            var chkremarks = document.getElementById("chkremarks");
            chkremarks.style.display = chkexamination.checked ? "block" : "none";
    }
    </script>

 

its not working


Answers (21)