Bonjour à Tous,

Avant tout, je vous souhaite une bonne année.
Dans le code joint, j'arrive à effectuer la somme mais "DE TOUTES LES CELLULES" alors que je souhaite calculer à la fois les lignes et chacune des colonnes.
Je suis débutant en JS et commence juste à comprendre.

Auriez vous des pistes afin de me guider vers la solution.
Bien à vous

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>SIMAG-Gestion des articles</title>
    <link rel="stylesheet" href="css/components.css">
    <link rel="stylesheet" href="css/icons.css">
    <link rel="stylesheet" href="css/responsee.css">
    <link rel="stylesheet" href="css/template-style.css">
    <link rel="stylesheet" href="css/pages.css">
    <link rel="stylesheet" href="css/general.css">
    <link href='https://fonts.googleapis.com/css?family=Playfair+Display&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,700,800&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
    <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui.min.js"></script>
 
    <!-- <script src="../js/clicDroit.js"></script> -->
    <script src="../js/script.js" defer></script>
    <title>Budget</title>
</head>
<body>
<?php include '../pages/connexion/navBudget.php' ?>    
<div class="tableau1">
    <input class="recherche" placeholder="Recherche par code article" id="maRecherche" onkeyup="filtrer()"><br><br>
    <table id="tableau" class="table table-striped table-hover">
      <form>  
        <thead>
            <tr>
                <th>#ID</th>
                <th>Libelle</th>
                <th>Abréviation</th>
                <th>Type</th>
                <th>Janvier</th>
                <th>Février</th>
                <th>Mars</th>
                <th>Avril</th>
                <th>Mai</th>
                <th>Juin</th>
                <th>Juillet</th>
                <th>Août</th>
                <th>Septembre</th>
                <th>Octobre</th>
                <th>Novembre</th>
                <th>Décembre</th>
                <th>Total</th>
            </tr>
        </thead>
        <tfoot>
        <tr>
          <td colspan="4">SUM</td>
          <td><span id="total" class="inp1" ></span></td>
        </tr>
      </tfoot>
        <tbody>
        <?php
        require_once '../pages/connexion/database.php';
        $categories = $pdo->query("SELECT RUB_ID,RUB_LIBELLE,RUB_ABREV,RUB_NATURE,RUB_TYPE FROM RUBRIQUES ")->fetchAll(PDO::FETCH_OBJ);
        foreach ($categories as $produit){
            ?>
            <tr>
                <td><?= $produit->RUB_ID ?></td>
                <td><?= $produit->RUB_LIBELLE ?></td>
                <td><?= $produit->RUB_ABREV ?></td>
                <td><?= $produit->RUB_NATURE ?></td>
                <td><input type="text" class="input_small_fee" name="fee1"></td>
                <td><input type="text" class="input_small_fee" name="fee2"></td>
                <td><input type="text" class="input_small_fee" name="fee3"></td>
                <td><input type="text" class="input_small_fee" name="fee4"></td>
                <td><input type="text" class="input_small_fee" name="fee5"></td>
                <td><input type="text" class="input_small_fee" name="fee6"></td>
                <td><input type="text" class="input_small_fee" name="fee7"></td>
                <td><input type="text" class="input_small_fee" name="fee8"></td>
                <td><input type="text" class="input_small_fee" name="fee9"></td>
                <td><input type="text" class="input_small_fee" name="fee10"></td>
                <td><input type="text" class="input_small_fee" name="fee11"></td>
                <td><input type="text" class="input_small_fee" name="fee12"></td>
                <td><input type="text" class="input_small_fee" name="fee13"></td>
            </tr>
            <?php
        }
        ?>
        </tbody>
    </form>  
    </table>
</div>
<script type="text/javascript">
     function addition() {
          result = 0;
          for (j=0; j<array.length; j++) {
               if ( array[j].value.length > 0 ) {
               if ( !/^\d+(\.\d{1,2})?$/.test(array[j].value) )
                    array[j].style.backgroundColor = "whitesmoke" ;
               else {
                    array[j].style.backgroundColor = "white";
                    result = parseFloat(result) + parseFloat(array[j].value);
                    }
               }                   
               }
          total.innerHTML = result.toString();
          }
     array = document.getElementsByClassName('input_small_fee') ;
     for (j=0; j<array.length; j++) { array[j].addEventListener("blur", addition) }
     document.forms[0].elements['fee1'].focus();
     
</script>
<Script src="../simag/js/produitRecherche.js"></Script>
 
</body>
</html>