bonjour j'ai réaliser un script qui permet de cloner des ligne de tableau et cela marche bien mais je bloque pour parcours les input et calculer la somme des valeurs
voici mon code pour mieux me comprendre
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 <form method="post" action="acceuil.php"> <!-- test table 2 --> <label>Numero Facture</label> <input type="text" required="required" name="num_fac" class="auto" /><span class="info"></span> <table id="table2" border="1"> <tr> <th></th> <th>Montant</th> <th>Date Echeance</th> <td><img src="images/add.png" class="cloneTableRows" /></td> </tr> <tr> <td><img src="images/del.png" alt="" class="delRow" style="visibility: hidden;" /></td> <td><input type="text" id="montant" required="required" name="mont[]" /> </td> <td><input type="text" required="required" name="date_echeance[]" class="my_date" /></td> <span class="montantvalide"></span> <td></td> </tr> <tr> <td><img src="images/del.png" alt="" class="delRow" style="visibility: hidden;" /></td> <td><input type="text" required="required" name="mont[]" /></td> <td><input type="text" required="required" name="date_echeance[]" class="my_date" /></td> <td></td> </tr> </table> <input id="buttonform" type="submit" name="button_echeance" value="valider" /> </form>
code pour le clonage
Code javascript : 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 $(document).ready(function(){ // -- Datepicker $(".my_date").datepicker({ dateFormat: 'yy-mm-dd', showButtonPanel: true }); //autocomplete $('body').delegate('.auto', 'focusin', function() { $('.auto').autocomplete({source: "autocomplete.php"}); }); // -- Clone table rows $(".cloneTableRows").live('click', function(){ // this tables id var thisTableId = $(this).parents("table").attr("id"); // lastRow var lastRow = $('#'+thisTableId + " tr:last"); // clone last row var newRow = lastRow.clone(true); // append row to this table $('#'+thisTableId).append(newRow); // make the delete image visible $('#'+thisTableId + " tr:last td:first img").css("visibility", "visible"); // clear the inputs (Optional) $('#'+thisTableId + " tr:last td :input").val(''); // new rows datepicker need to be re-initialized $(newRow).find("input").each(function(){ if($(this).hasClass("hasDatepicker")){ // if the current input has the hasDatpicker class var this_id = $(this).attr("id"); // current inputs id var new_id = this_id +1; // a new id $(this).attr("id", new_id); // change to new id $(this).removeClass('hasDatepicker'); // remove hasDatepicker class // re-init datepicker $(this).datepicker({ dateFormat: 'yy-mm-dd', showButtonPanel: true }); } }); return false; }); // Delete a table row $("img.delRow").click(function(){ $(this).parents("tr").remove(); return false; }); });
jusqu’à ici j'ai pas de problème
mais je bloque pour parcours cette ligne
et calculer la somme des montant
Code html : Sélectionner tout - Visualiser dans une fenêtre à part <td><input type="text" id="montant" required="required" name="mont[]" /> </td>
merci d'avance pour votre aide
Partager