Select + onchange + php

Résolu/Fermé
yoshiro Messages postés 497 Date d'inscription jeudi 1 novembre 2007 Statut Membre Dernière intervention 18 avril 2018 - 12 avril 2018 à 04:09
yoshiro Messages postés 497 Date d'inscription jeudi 1 novembre 2007 Statut Membre Dernière intervention 18 avril 2018 - 18 avril 2018 à 01:05
Voici mon code :

function refresh_div(val) {
 
      $.ajax({
            type: 'POST',
            url: '',
            data: {
                get_option: val
            },
            success: function (response) {
                alert(val);
                <?php
          $list_tick = lists_tickets('', 100);
          ?>
                $("#dataTable").load(" #dataTable > *");
            }
        });
}


et le rendu :

<select name="temps" onchange="refresh_div(this.value)">
<option value="4">4</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option
</select> Jours

....
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Statut</th>
                        <th>Source</th>
                        <th>Priorité</th>
                        <th>Catégorie</th>
                        <th>Titre</th>
                        <th>Contenue</th>
                        <th>Demandeur</th>
                        <th>Technicien</th>
                        <th>Date d'ouverture</th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th>ID</th>
                        <th>Statut</th>
                        <th>Source</th>
                        <th>Priorité</th>
                        <th>Catégorie</th>
                        <th>Titre</th>
                        <th>Contenue</th>
                        <th>Demandeur</th>
                        <th>Technicien</th>
                        <th>Date d'ouverture</th>
                    </tr>
                </tfoot>
                <tbody>
                    <?php
                        $list_tick = lists_tickets('',$_POST['get_option']);
                        for($j = 0; $j < count($list_tick["id"]); $j++) {   
                            echo "<tr>";
                                echo "<td>".$list_tick['id'][$j]."</td>";
                                echo "<td>".$list_tick['status'][$j]."</td>";
                                echo "<td>".$list_tick['name'][$j]."</td>";
                                echo "<td>".$list_tick['priority'][$j]."</td>";
                                echo "<td>".$list_tick['cat'][$j]."</td>";
                                echo "<td>".$list_tick['title'][$j]."</td>";
                                echo "<td>".$list_tick['desc'][$j]."</td>";
                                echo "<td>".$list_tick['deman'][$j]."</td>";
                                echo "<td>".$list_tick['techn'][$j]."</td>";
                                echo "<td>".$list_tick['dateouv'][$j]."</td>";
                            echo "</tr>";
                        }
                    ?>
                </tbody>
            </table>


Mon but c'est de recharger le tableau avec les données envoyées, sans recharger toute la page.

Je suis bloqué le tableau ne récupère pas les nouvelles tableaux. Mon tableau est généré avec le datables.boostrap4.js.

Merci par avance !
A voir également:

2 réponses

jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
12 avril 2018 à 07:17
Bonjour
Tu ne peux pas executer de php dans du javascript...
Tu dois boucler sur le résultat de ton ajax en js et re-ecrire toi même les lignes de ton tableau.
0
jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
12 avril 2018 à 07:18
0