mardi 30 octobre 2018

How To implement User checkbox checked and show multiple TextBox

I Have A CheckBox And Multipe TextBox

    @Html.CheckBox("myCheck", new { @onclick = "myFunction()" })

I have Script

<script>
 function myFunction() {
 // Get the checkbox
 var checkBox = document.getElementById("myCheck");

 // Get the output TextBox
 var text = document.getElementById("t1");
 var text = document.getElementById("t2");
 var text = document.getElementById("t3");

 // If the checkbox is checked, display the output TextBox
 if (checkBox.checked == true){
 text.style.display = "block";
 } else {
 text.style.display = "none";
 }
 }
</script>

if user click on the checkbox as well as all the text box shows if user click unchecked checkbox then hide all TextBox

@Html.TextBox("t1",null,new{@class="form-control", hidden})
@Html.TextBox("t2",null,new{@class="form-control", hidden})
@Html.TextBox("t3",null,new{@class="form-control", @rows="10", hidden})

How do i implement please help me i am new in mvc




Aucun commentaire:

Enregistrer un commentaire