Bonjour
Sur plusieurs pages, j'utilise datatables.
Sur l'une d'elles, je souhaiterais faire une sélection de certaines lignes et les envoyer via une formulaire.
Dans les script, que je joins, il y a donc une partie qui gère l'affichage en datatable, et la deuxième qui récupère les checkboxes, les entre dans une variable data. Ensuite j'affiche une alerte avec le contenu de ma variable (dans un premier temps, après je devrai faire l'envoie vers une autre page pour le traitement)
Seulement, plus d'affichage en datatable, et du coup le reste, ne fonctionne pas non plus :/
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 $(document).ready(function() { $('#example6').DataTable( { "language": { "sProcessing": "Traitement en cours...", "sSearch": "Rechercher :", "sLengthMenu": "Afficher _MENU_ éléments", "sInfo": "Affichage de l'élément _START_ à _END_ sur _TOTAL_ éléments", "sInfoEmpty": "Affichage de l'élément 0 à 0 sur 0 élément", "sInfoFiltered": "(filtré de _MAX_ éléments au total)", "sInfoPostFix": "", "sLoadingRecords": "Chargement en cours...", "sZeroRecords": "Aucun élément à afficher", "sEmptyTable": "Aucune donnée disponible dans le tableau", "oPaginate": { "sFirst": "Premier", "sPrevious": "Précédent", "sNext": "Suivant", "sLast": "Dernier" }, "oAria": { "sSortAscending": ": activer pour trier la colonne par ordre croissant", "sSortDescending": ": activer pour trier la colonne par ordre décroissant" } }, dom: 'Bfrtip', buttons: [ 'csv', 'excel',{ extend : "pdf", text: 'PDF', orientation: 'landscape', exportOptions: { stripHtml: false }, footer: function(currentPage, pageCount) { return currentPage.toString() + ' sur ' + pageCount; }, }, ] } ); $('#selectrefofval').change(function() { var checkboxes = document.getElementById("my_form").getElementsByTagName("input"); var u = 1; for (var i = 0, iMax = checkboxes.length; i < iMax; ++i) { var check = checkboxes[i]; if (check.type == "checkbox" && check.checked && u = 1) { data = check.value; u = u + 1; } if (check.type == "checkbox" && check.checked && u>1) { data = data+'|'+check.value; u = u + 1; } } alert( "The following data would have been submitted to the server: \n\n"+ data ); return false; } ); } );
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
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 <div class="col-lg-12 col-md-12 col-sm-12" style="margin-top:15px;"> <form id="my_form" name="my_form" method="post"> <select id="selectrefofval" class="form-control form-control-sm selectrefofval" > <option value="">Choisir son action</option> <option value="http://www.yahoo.fr/">Accepter</option> <option value="http://www.msn.com/">Refuser</option> </select> <table width="100%" class="table table-striped table-bordered dt-responsive nowrap" id="example2"> <thead> <tr> <th></th> <th>'.ELABO_ART.'</th> <th>'.ELABO_LIB.'</th> <th>'.ELABO_M_R_N0.$annee_n0_annee.'</th> <th>'.ELABO_M_R_A.'</th> <th>'.ELABO_M_R_P.'</th> <th>'.ELABO_M_NR_N0.$annee_n0_annee.'</th> <th>'.ELABO_M_NR_P.'</th> <th>'.WORKFLOW.'</th> <th></th> <th></th> <th></th> </tr> </thead> <tr> <td><input class="form-check-input" type="checkbox" value="1" name="checkbox1_name"></td> <td v-align="center" align="center">'.$articles_article.'</td> <td v-align="center" align="center">'.$articles_libelle.'</td> <td v-align="center" align="center">'.$elabo_n0_montant_arrondi.'</td> <td v-align="center" align="center">'.$elabo_n1_montant_auto_arrondi.'</td> <td v-align="center" align="center">'.$elabo_proj_n1_montant1.'</td> <td v-align="center" align="center">'.$elabo_n0_montant_nr_arrondi.'</td> <td v-align="center" align="center">'.$elabo_proj_n2_montant1.'</td> <td v-align="center" align="center">'.$choix_workflow_lib1.'</td> <td v-align="center" align="center"> <a href="elabo_budg_zoom_ordi.php?id='.$soc_choix.'&art='.$articles_id.'"> <img src="../images/afficher.png" alt="Visionner"> </a> </td> <td v-align="center" align="center"> <a href="elabo_budg_art_valid.php?id='.$soc_choix.'&art='.$articles_id.'"> <img src="../images/fleche.jpg" alt="Valider"> </a> </td> <td v-align="center" align="center"> <a href="elabo_budg_art_refus.php?id='.$soc_choix.'&art='.$articles_id.'"> <img src="../images/fleche_r.png" alt="Refuser"> </a> </td> </tr>'; } } echo' </table> </form> </div>
Partager