Reputation: 2339
I have a table which have list of rows and every row have two checkboxes what I am trying to do is when someone check on check box it send request to server using ajax and reponsev with data if it pass it change the tr color to green if fail it change to red..I am done with this step
Now I want when it is success it should enable other check box which is on the same tr so now user can process with the second step.
$("#SendReview").click(function() {
var selected = "";
$('.ReviewForm').each(function() {
selected = selected + "," + $(this).attr('id');
});
$.ajax({
url: '@Url.Action("VerifyFormRquest", "Results")',
type: "POST",
data: {
scanid: selected
},
success: function(data, textStatus, jqXHR) {
alert(data.success);
data.success.split(',').forEach(function(c) {
if (c != "") {
var m = $('#example tr:has(td:contains(' + c + '))').css('background-color', 'lightgreen');
}
});
},
error: function(jqXHR, textStatus, errorThrown) {}
});
});
<table id="example">
<tr id="1000000107">
<td>
<input type="checkbox" id="J15000001" scanid="1000000103" onclick="call()" disabled="disabled" value="1000000103" class="ELOchecked">
</td>
</tr>
<tr id="1000000107">
<td>
<input type="checkbox" id="J15000012" scanid="1000000107" disabled="disabled" value="1000000107" class="ELR">
</td>
</tr>
</table>
Upvotes: 1
Views: 728
Reputation: 67505
Since you already have the pattern to get the td
you could get the next one using next('td')
:
var current_td = $('#example td:contains('+ c +')');
//If the current td found get the next one and remove the disabled property
if( current_td.length > 0 ){
current_td.next('td').prop('checked',false);
}
Upvotes: 1
Reputation: 23738
you should use
("#J15000012").prop("disabled",false);
to check the checkbox rather than using the .removeAttr
as it does not set the value to false
as of jquery 3
Upvotes: 1
Reputation: 2588
You can do this by using the prop
method.
$("#myOtherCheckbox").prop("disabled", false);
If you want to add a class to it as well:
$("#myOtherCheckbox").prop("disabled", false).addClass("someClass");
Upvotes: 1