JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<tr>
<td>
<select id="Select0Box_C">
<option value="0">Aircraft</option>
<option value="Bus">Bus</option>
</select>
<input id="Text0Box_Q1" />
</td>
<td>
<select id="Select1Box_C">
<option value="0">Aircraft</option>
<option value="Bus">Bus</option>
</select>
<input id="Text1Box_Q1" />
</td>
<td>
<select id="Select2Box_C">
<option value="0">Aircraft</option>
<option value="Bus">Bus</option>
</select>
<input id="Text2Box_Q1" />
</td>
</tr>
</table>
JavaScript
$(function () {
for(var i=0;i<3;i++){ //loop through each of the rows
$("#Select" + i + "Box_C").change(callbackFactory(i)); //This is a working function
$("#Select" + i + "Box_C").change(function(n){return function(){toBus(n);};}(i)); //This one isn't working
$("#Text" + i + "Box_Q1").prop('disabled', true); //this one is working
};
function busEnabler(num){
$("#Text" + num + "Box_Q1").prop('disabled', false);
};
function callbackFactory(num){
console.log(num);
};
function toBus(numm){
alert(numm);
var jk = numm; //Closures confuse me
if ($("#Select" + numm + "Box_C").val() === "Bus"){
$("#Text" + numm + "Box_Q1").prop('disabled', false);
console.log(jk);
busEnabler(jk);
}
else {
$("#Text" + numm + "Box_Q1").prop('disabled', true);
console.log($("#Select" + numm + "Box_C") + "=" + $("#Select" + numm + "Box_C").val());
}
};
});