Bonsoir
j'ai une boucle qui me crée des boutons, je veux quand je clique sur un bouton j'ajoute une ligne dans mon tableau,
chaque bouton ajout des informations précises
get_parametre.php
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 <?php include ("dossier_id.php"); ?> <script> function get_parametre(id) { alert(id); $.ajax({ type : 'POST', url : 'get_parametre.php', data: 'id='+id, success : function(data){ alert(data); }, error : function(XMLHttpRequest, textStatus, errorThrown) { alert(55); } }); } </script> <section class="container-table"> <caption class="entete-table">Liste des Paramètres Analyse</caption> <form id="frm" method="POST" class="formusimple"> <button type="button" onclick="foo()">Click Me</button> <?php $req="SELECT * FROM parametre_analyse WHERE existe='1' "; $res=mysql_query($req); while($row=mysql_fetch_array($res)) { ?> <input type="submit" value="<?php echo $row['label'];?>" id="<?php echo $row['id_parametre'];?>" onclick="get_parametre(this.id)" name="enregistrer" class="btn"> <?php } ?> </form> </section> <section class="container-table"> <table name="tab" id="tab" width="100%" cellspacing="1" class="tableau"> <tbody> </tbody> </table> </section>
Code php : 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 session_start(); include("connexion.php"); $id=$_REQUEST['id']; $req="SELECT * FROM parametre_analyse WHERE existe='1' AND id_parametre='$id' "; $res=mysql_query($req); $row=mysql_fetch_array($res); echo '<tr> <td height="40" align="center" bgcolor="#FFFFFF">'.$row['label'].'</td> <td height="40" align="center" bgcolor="#FFFFFF">'.$row['label'].'</td> <td height="40" align="center" bgcolor="#FFFFFF">'.$row['designation'].'</td> <td height="40" align="center" bgcolor="#FFFFFF">'.$row['prix'].'</td> </tr> ';
mon problème c'est que en cliquant sur le bouton la fonction AJAX ne marche pas
Partager