Bonjour,
En cliquant sur un bouton, J'arrive a cloné ou dupliqué le tr de mon tableau avec tous les champs input de type text.
Mon souci est de pouvoir enregistrer l données de chaque champs dans la table de presences qui est dans la bdd.
AIDEZ MOI SVP
voici un model
Voici le code:
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 <table class="table table-bordered"> <h5><strong>LISTE DE PRESENCE </strong></h5> <hr> <thead> <tr> <th scope="col">ENTREPRISE</th> <th scope="col">NOM ET PRENOM</th> <th scope="col">FONCTION</th> <th scope="col">NUMERO PIECE DIDENTITE </th> </tr> </thead> <tbody> <tr> <th scope="row" colspan=""> <div class="form-group" id="01"> <input type='text' name="entreprise[]" class='form-control form-control-sm'> </div> </th> <td><div class="form-group" id="01"> <input type='text' name="nomPrenom[]" class='form-control form-control-sm'> </div> </td> <td><div class="form-group" id="01"> <input type='text' name="fonction[]" class='form-control form-control-sm'> </div> </td> <td><div class="form-group" > <input type='text' name="num_ident[]" class='form-control form-control-sm'> </div> </td> </tr> <tr class="d-none" id="dup"> <th scope="row" colspan=""> <div class="form-group"> <input type='text' name="entreprise[]" class='form-control form-control-sm'> </div> </th> <td><div class="form-group"> <input type='text' name="nomPrenom[]" class='form-control form-control-sm'> </div> </td> <td><div class="form-group"> <input type='text' name="fonction[]" class='form-control form-control-sm'> </div> </td> <td><div class="form-group"> <input type='text' name="ident[]" class='form-control form-control-sm'> </div> </td> </tr> <tr> <td colspan="4"><span> <a href="#" class="btn btn-outline-primary btn-sm" id="btn">Ajouter une ligne</a></span></td> </tr> </tbody> </table>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7<script> $('#btn').click(function(e) { e.preventDefault(); var $clone = $('#dup').clone().attr('id', '').removeClass('d-none').appendTo('#01'); $('#dup').before($clone); }) </script>









Répondre avec citation







sur jreaux. Si la ligne est dupliquée en JS, il vaut mieux qu'il n'y ait pas d'index explicite. Sinon, il va falloir éditer les champs pour modifier l'index.
Affichez votre code en couleurs : [CODE=php][/CODE] (bouton # de l'éditeur) et [C=php][/C]




Partager