forum

Home / DeveloperSection / Forums / How to get checkbox value in Asp.net mvc?`

How to get checkbox value in Asp.net mvc?`

Anonymous User 2541 14-Apr-2015

I'm creating a table.I want to get selected checkbox value.

<tr>
  <td>
    @item
    <input type="hidden" value="@item" name="@item"class="chkbx" id="ControllerName" />
  </td>
  <td>                   
    <input type="checkbox" id="Iscreate" value="@Create"class="chkbx" />
  </td>
  <td>
    <input type="checkbox" id="IsDelete" value="@Delete" class="chkbx" />
  </td>
  <td>
    <input type="checkbox" id="IsView" value="@View" class="chkbx" />
  </td>
  <td>
    <input type="checkbox" id="IsEdit" value="@Edit" class="chkbx" />
  </td>
  <td>
    <input type="checkbox" id="IsDownload" value="@Download" class="chkbx" />
  </td>
</tr>
Jquery code I use
<script type="text/javascript">
  $('input[type=checkbox]').change(function () {
    var vales =$("#ControllerName").val();
    var vals =$('input[class=chkbx]:checked').map(function () {
      return $(this).val();
    }).get().join(',');
    $('#debug').val(vals);
  });
</script>

Basically this code create a Value in hidden Field Like this

3-Create-Account,3-Delete-Account,3-View-Account,3-Edit-Account,3-Download-Account

But Actually i need this

3-Account-Create-Delete-Edit-Download-view,4-Account-Create-Delete-Edit-Download-view, 5-Account-Create-Delete-Edit-Download-view


Updated on 14-Apr-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By