asp.net mvc - How to check if checkbox is checked in view page with razor and if checked display a textbox -


how can check if checkbox checked in view page razor , if checked display textbox!

i'm new in asp.net mvc , razor, still learning.

view code

@html.checkboxfor(m => m.supportrequired)     @html.textboxfor(m => m.assistname new { @class = "form-control" }) 

you can use javascript this:

@html.checkboxfor(m => m.supportrequired , new { id = "mychk", onchange = "valuechanged()"})   @html.textboxfor(m => m.assistname , new { id = "mytxt" , @class = "form-control" })  <script type="text/javascript">     function valuechanged() {         if ($('#mychk').is(":checked"))             $("#mytxt").show();         else             $("#mytxt").hide();     } </script> 

edit

for show or hide in page load need add code:

$(document).ready(function() {     valuechanged(); }); 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -