Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i wrote a html code to display the table information in disable mode. but if i click on the check box/boxes, those checked row/rows should be in editable mode.

HTML
<tbody>
                        
                          @foreach(StudentsEnquire enqire in Model.StudentEnquire)
                          {
                              <tr>
                                  <td>@Html.CheckBox("status"+enqire.StudentId, new { value = enqire.StudentId, @class = "EnquireCheckBox" })</td>
                                  <td>@Html.TextBox(enqire.SName, enqire.SName, new { @class = "textdisable", @disabled = "disabled" })</td>
                                  <td>@Html.TextBox(enqire.SCourse, enqire.SCourse, new { @class = "textdisable", @disabled = "disabled" })</td>
                                  <td>@Html.TextBox(enqire.SQualification, enqire.SQualification, new { @class = "textdisable", @disabled = "disabled" })</td>
                                  <td>@Html.TextBox(enqire.SContact, enqire.SContact, new { @class = "textdisable", @disabled = "disabled" })</td>
                                  <td>@Html.TextBox(enqire.email, enqire.email, new { @class = "textdisable", @disabled = "disabled" })</td>
                                  <td>@Html.TextBox(enqire.SAddress, enqire.SAddress, new { @class = "textdisable", @disabled = "disabled" })</td>
                                  <td>@Html.TextBox(enqire.Remarks, enqire.Remarks, new { @class = "textdisable", @disabled = "disabled" })</td>
                              </tr>
                          }
                        
                    </tbody>


jquery code:

JavaScript
$('.EnquireCheckBox').click(function () {


       var result = $('input[type="checkbok"]:checked').closest('tr').children();

       if ($(this).prop("checked") == true) {
           $('.textdisable').prop('disabled', false);
         var value = $(this).val();

                   }

       else if ($(this).prop("checked") == false) {


       }

   });


this jquery code is enabling all the text boxes which are not checked also

What I have tried:

i wrote a html code to display the table information in disable mode. but if i click on the check box/boxes, those checked row/rows should be in editable mode.

this jquery code is enabling all the text boxes which are not checked also
Posted
Updated 29-Feb-16 0:57am

1 solution

Try this:
JavaScript
$('input[type=checkbox]').on('click', function() {          
  $(this).closest('td').siblings().find('input[type="text"]').attr('disabled', !this.checked);
});
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900