Calculer la some des colones avec jquery
<!DOCTYPE html>
<html>
<head>
<title>CALCULER LA SOME DES COLONES AVEC JQUERY | par NGLESSON </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Mezgani said">
<meta name="copyright" content="NGLESSON">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row mt-5">
<div class="col-lg-12">
<table class="table table-hover" id="table21">
<thead class="text-center table-secondary">
<tr>
<th>row 1 </th>
<th>row 2</th>
<th>row 3</th>
<th>row 4</th>
<th>riw 5</th>
<th>TOTAL</th>
</tr>
</thead>
<tbody id="tbodyCulture">
<tr id="R1" class="1">
<td><input type="number" class='txtCalcul1' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)"></td>
<td><input type="number" class='txtCalcul1' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)" /></td>
<td><input type="number" class='txtCalcul1' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)" /></td>
<td><input type="number" class='txtCalcul1' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)" /></td>
<td><input type="number" class='txtCalcul1' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)" /></td>
<td><input id="totalc1" type="number" class='txttotal' value="0" readonly disabled /></td>
</tr>
<tr id="R2" class="2">
<td><input type="number" class='txtCalcul2' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)"></td>
<td><input type="number" class='txtCalcul2' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)" /></td>
<td><input type="number" class='txtCalcul2' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)" /></td>
<td><input type="number" class='txtCalcul2' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)" /></td>
<td><input type="number" class='txtCalcul2' onkeydown="calculeRowsCulture(this)" onkeyup="calculeRowsCulture(this)" /></td>
<td><input id="totalc2" type="number" class='txttotal' value="0" readonly disabled /></td>
</tr>
</tbody>
</table>
</div>
<div class="col-lg-12"><hr /></div>
<div class="col-lg-12">
<table class="table table-hover" id="table2">
<thead class="text-center table-secondary">
<tr>
<th>row 1 </th>
<th>row 2</th>
<th>row 3</th>
<th>row 4</th>
<th>riw 5</th>
<th>TOTAL</th>
</tr>
</thead>
<tbody id="tbodyPlnatation">
<tr id="L1" class="1">
<td><input type="number" class='txtCalplantation' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)"></td>
<td><input type="number" class='txtCalplantation1' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)" /></td>
<td><input type="number" class='txtCalplantation1' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)" /></td>
<td><input type="number" class='txtCalplantation1' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)" /></td>
<td><input type="number" class='txtCalplantation1' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)" /></td>
<td><input id="totalp1" type="number" class='txttotal' value="0" readonly disabled /></td>
</tr>
<tr id="L2" class="2">
<td><input type="number" class='txtCalplantation2' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)"></td>
<td><input type="number" class='txtCalplantation2' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)" /></td>
<td><input type="number" class='txtCalplantation2' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)" /></td>
<td><input type="number" class='txtCalplantation2' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)" /></td>
<td><input type="number" class='txtCalplantation2' onkeydown="calculeRowsPlantation(this)" onkeyup="calculeRowsPlantation(this)" /></td>
<td><input id="totalp2" type="number" class='txttotal' value="0" readonly disabled /></td>
</tr>
</tbody>
</table>
</div>
<div class="col-lg-12"><hr /></div>
<div class="col-lg-12">
<table class="table table-hover" id="table3">
<thead class="text-center table-secondary">
<tr>
<th>row 1 </th>
<th>row 2</th>
<th>row 3</th>
<th>row 4</th>
<th>riw 5</th>
<th>TOTAL</th>
</tr>
</thead>
<tbody id="tbodySaiid">
<tr id="S1" class="1">
<td><input type="number" class='txtCalsaid1' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)"></td>
<td><input type="number" class='txtCalsaid1' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)" /></td>
<td><input type="number" class='txtCalsaid1' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)" /></td>
<td><input type="number" class='txtCalsaid1' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)" /></td>
<td><input type="number" class='txtCalsaid1' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)" /></td>
<td><input id="totals1" type="number" class='txttotal' value="0" readonly disabled /></td>
</tr>
<tr id="S2" class="2">
<td><input type="number" class='txtCalsaid2' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)"></td>
<td><input type="number" class='txtCalsaid2' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)" /></td>
<td><input type="number" class='txtCalsaid2' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)" /></td>
<td><input type="number" class='txtCalsaid2' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)" /></td>
<td><input type="number" class='txtCalsaid2' onkeydown="calculeRows(this)" onkeyup="calculeRows(this)" /></td>
<td><input id="totals2" type="number" class='txttotal' value="0" readonly disabled /></td>
</tr>
</tbody>
</table>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="script.js"></script>
</body>
</html>
function calculeRowsCulture(input){
calculateInit($(input).attr('class'), $(input).val(), $(input).closest('tr').attr('id'), $(input).closest('tr').attr('class'));
}
function calculateInit(classnameinput, valueinput, elementid, numberofrow){
$('#tbodyCulture #'+elementid).on('input', '.'+classnameinput, function () {
var totalc = 0;
$('#tbodyCulture .'+classnameinput).each(function () {
var get_textbox_culture = $(this).val();
if ($.isNumeric(get_textbox_culture)) {
totalc += parseFloat(get_textbox_culture);
}
});
$('#totalc'+numberofrow).val(totalc);
});
}
function calculeRowsPlantation(input){
calculatePlantation($(input).attr('class'), $(input).val(), $(input).closest('tr').attr('id'), $(input).closest('tr').attr('class'));
}
function calculatePlantation(classnameinput, valueinput, elementid, numberofrow){
$('#tbodyPlnatation #'+elementid).on('input', '.'+classnameinput, function () {
var totalp = 0;
$('#tbodyPlnatation .'+classnameinput).each(function () {
var get_textbox_plantation = $(this).val();
if ($.isNumeric(get_textbox_plantation)) {
totalp += parseFloat(get_textbox_plantation);
}
});
$('#totalp'+numberofrow).val(totalp);
});
}
function calculeRows(input){
calculateISsaidnit($(input).attr('class'), $(input).val(), $(input).closest('tr').attr('id'), $(input).closest('tr').attr('class'));
}
function calculateISsaidnit(classnameinput, valueinput, elementid, numberofrow){
$('#tbodySaiid #'+elementid).on('input', '.'+classnameinput, function () {
var totals = 0;
$('#tbodySaiid .'+classnameinput).each(function () {
var get_textbox_said = $(this).val();
if ($.isNumeric(get_textbox_said)) {
console.log($(this).attr('class'));
totals = 1+4-1;
//totals += parseFloat(get_textbox_said);
}
});
$('#totals'+numberofrow).val(totals);
});
}