Bonjour,

J'ai un problème concernant un tableau de calcule.
Je dois remplir un tableau grâce à une requête et php.
Ensuite je fais un foreach{} sur le resultat. Jusque là tout va bien.

Dans ce tableau, j'ai des champs input avec un id automatique en utilisant une clé ! Pour faire mes calcules, j'ai besoin de récupérer les valeurs de ces champs grâce à l'ID seulement je ne sais pas comment le passer à ma fonction js.
Code html : 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
<form method="post">
                <h3>IMB</h3>
                <table id="ftth" class="display table table-bordered table-hover list-com">
                    <thead>
                    <tr>
                        <th>Dossier</th>
                        <th>Date de chargement Dossier minute</th>
                        <th>EL calculé</th>
                        <th>El effectif</th>
                        <th>Prix calculé</th>
                        <th>Ville</th>
                        <th class="text-center">Attacher</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($imb as $c):
                        $date = new DateTime($c->date_minute);
                        ?>
                        <tr>
                            <td><?= $c->dossier;?></td>
                            <td><?= $date->format('d-m-Y');?></td>
                            <td><?= $c->nb_logements;?></td>
                            <td><input type="number" class="form-control input-sm" name="<?= 'el_'.$c->dossier;?>" value="<?= $c->nb_logements;?>" onChange="calcul()"></td>
                            <td class="text-right">
                                <input type="hidden" id="<?= 'PU_'.$c->dossier;?>" name="<?= 'PU_'.$c->dossier;?>" value="<?= $c->prix;?>"  onblur="calcul()">
                                <input type="number" id="<?= 'PT_'.$c->dossier;?>" class="form-control input-sm" name="<?= 'PT_'.$c->dossier;?>" readonly>
                                <?php
                                $total = $c->nb_logements*$c->prix;
                                echo $total.' €';
                                ?>
                            </td>
                            <td><?= $c->localite;?></td>
                            <td class="text-center">
                                <input name="<?= 'chek_'.$c->dossier;?>" type="checkbox">
                            </td>
                        </tr>
                    <?php endforeach;?>
                    </tbody>
                </table>
                <button type="submit" name="submit" class="btn btn-success pull-right btn-com">Valider</button>
                <button type="button" name="submit" class="btn btn-primary pull-right btn-com">Recalculer</button>
 
            </form>