PHP Useless, попробуйте разобраться, коэффициент добавляет в теге предмета data-k, функции изменены
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<table width="400" class="qrup" >
<thead>
<tr>
<th>Fənnlər</th>
<th>D</th>
<th>Y</th>
<th>FB</th>
</tr>
</thead>
<tbody>
<tr class="study" data-k="1">
<td>Родной язык</td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr class="study" data-k="2">
<td>Математика</td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr class="study" data-k="2">
<td>Физика</td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr>
<td colspan="2" ></td>
<td >Sizin Balınız</td>
<td class="result"></td>
</tr>
</tbody>
</table>
<table width="400" class="qrup" >
<thead>
<tr>
<th>Fənnlər</th>
<th>D</th>
<th>D-A</th>
<th>Y</th>
<th>FB</th>
</tr>
</thead>
<tbody>
<tr class="study" data-k="1">
<td>Родной язык</td>
<td><input name=""></td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr class="study" data-k="2">
<td>Математика</td>
<td><input name=""></td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr class="study" data-k="2">
<td>Физика</td>
<td><input name=""></td>
<td><input name=""></td>
<td><input name=""></td>
<td class="interim"></td>
</tr>
<tr>
<td colspan="3" ></td>
<td>Sizin Balınız</td>
<td class="result"></td>
</tr>
</tbody>
</table>
<script>
var fb = [function(a, b) { //формулы для каждой таблицы по порядку
return 4 * a - b
}, function(a, b, c) {
return 4 * a + b - c
}],
total = function(a) {
return a.reduce(function(a, b) {
return a + b
}, 0)
};
[].forEach.call(document.querySelectorAll(".qrup"), function(table, i) {
var sum = [],
result = table.querySelector(".result");
[].forEach.call(table.querySelectorAll(".study"), function(tr, n) {
var temp = [],
interim = tr.querySelector(".interim"), k = +tr.dataset.k||1;
sum[n] = 0;
[].forEach.call(tr.querySelectorAll("input"), function(input, j) {
temp[j] = 0;
input.addEventListener("input", function() {
var val = +input.value || 0;
input.value = temp[j] = val;
sum[n] = fb[i].apply(null, temp) * k;
interim.innerHTML = sum[n];
result.innerHTML = total(sum)
})
})
})
});
</script>
</body>
</html>