Quantcast
Channel: User mykhailovskyi - Stack Overflow
Viewing all articles
Browse latest Browse all 29

Answer by mykhailovskyi for ASP.NET MVC Checboxes disabling/enabling textboxes

$
0
0

You may set counter and create unique class or some attribute for each block. For example:

<table id="myTable">
     @{
            int c = 0;
            for(int i = 0; i < Model.Count; i++)
            {
                c++;
                <tr class="@("block"+c)">
                    <td>
                        @Html.CheckBox("name", new {data_block=c})
                    </td>
                    <td>
                        @Html.EditorFor(m => item.Toolbox)
                    </td>
                    <td>
                        @Html.EditorFor(m => item.Name)
                    </td>
                    <td>
                        @Html.EditorFor(m => item.Link)
                    </td>
                </tr>
            }
</table>

and then javascript code:

$(function(){
        $('#myTable checkboxes').click(function(){
            var checkbox = $(this),
            blockNum = checkbox.data('block'),
            inputs = $('tr.block'+blockNum),
            state = checkbox.is(':checked');

            $.each( inputs, function( i, el ){
                $(el).prop("disabled", state);
            });
        });
    });

Viewing all articles
Browse latest Browse all 29

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>