0
$('#tab_logic tbody tr').each(function(i, element){
    var y=1;

    y++;

    $('#ProductId'+y).attr('disabled', 'disabled');
    $('#ProductName'+y).attr('disabled', 'disabled');
    $('#AvailableQuantity'+y).attr('disabled', 'disabled');
    $('#LastPurchaseCost'+y).attr('disabled', 'disabled');
    $('#MinimumLevelQuantity'+y).attr('disabled', 'disabled');
});
Natrium
  • 29,076
  • 15
  • 55
  • 71
  • Does this answer your question? [disable textbox using jquery?](https://stackoverflow.com/questions/1648901/disable-textbox-using-jquery) – Natrium Dec 12 '19 at 05:19
  • Syntax to disable seems correct, so my guess would be there's something wrong with the selector(s) you are using. Hard to tell with the few amount of info you are providing us. – Natrium Dec 12 '19 at 05:21

2 Answers2

0

I think I know your problem, you have a table, and inside each row you put those textbox with same ID, that the reason, in HTML you all the ID is unique, so if you use $("#ID") will only choose first element.

try to use class. like .productId, so in each row will be $(this).find(".productId").prop("disabled", true).

BeiBei ZHU
  • 278
  • 1
  • 11
0

You just need to declare a global variable.

var y=0;
$('#tab_logic tbody tr').each(function(i, element){
    $('#ProductId'+y).attr('disabled', 'disabled');
    $('#ProductName'+y).attr('disabled', 'disabled');
    $('#AvailableQuantity'+y).attr('disabled', 'disabled');
    $('#LastPurchaseCost'+y).attr('disabled', 'disabled');
    $('#MinimumLevelQuantity'+y).attr('disabled', 'disabled');
    y++;
});
Dhaval Soni
  • 325
  • 1
  • 11