Bonjour,
lors du développement d'un de mes petits projets, je tombe sur un os !!
en effet, mon script d'autocompletion marche parfaitement, mais lors du clic sur un résultat pour afficher plus de détail dans une autre div, il y a des bug
le contenu de cette div ne se met pas bien a jour
script de l'index :
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 <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <meta charset="UTF-8"> <title>UN probleme ?La solution est Ici avec T@GGLE</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Language" content="fr" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="expires" content="0" /> <meta name="revisit-after" content="10 DAYS" /> <meta name="robots" content="INDEX, FOLLOW" /> <meta name="resource-type" content="DOCUMENT" /> <meta name="distribution" content="GLOBAL" /> <meta name="rating" content="general" /> <meta name="author" content="COUVERCELLE" /> <meta name="keywords" content="" /> <meta name="generator" content="" /> <meta name="copyright" content="Copyright (c) 2013 by COUVERCELLE" /> <meta name="description" content="" /> <meta name="google-site-verification" content="" /> <link rel="stylesheet" href="css/style.css" type="text/css" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="cfg/search.js"></script> <script type="text/javascript" src="cfg/fctn.js"></script> </head> <body> <header> </header> <section id="left"> <nav> <input type="text" name="recherche" class="text" id="recherche"/> </nav> <article id="resultat"></article> </section> <section id="right"> <article id="cont"></article> </section> <footer> </footer> </body> </html>
script du resultat autocomplete
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 <?php include_once 'cnx.php'; if(isset($_GET['motclef'])){ $motclef = $_GET['motclef']; $q = array('motclef'=>'%'.$motclef.'%'); $sql = 'SELECT id,nom,aide FROM fichiers WHERE nom like :motclef or aide like :motclef'; $req = $cnx->prepare($sql); $req->execute($q); $count = $req->rowCount($sql); if($count){ while ($result = $req->fetch(PDO::FETCH_OBJ)){ echo "<p class=\"action\" onclick=\"voir(".$result->id.")\">Titre :".$result->nom."<br/>Message:".$result->aide."</p><br/><br/>"; } }else{ echo "Aucun resultat pour :".$motclef; } } ?>
script du js de ma fonction appelée
et enfin ma page voir.php (pour le moment il n'y a pas grand chose car je test la fonction avant de developper le contenu)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 function voir(id){ $(function() { $('.action').click(function() { var param = 'l=' + id; $("#cont").empty(); $('#cont').load('scripts/voir.php',param); }); }); }
si vous voulez voir un peu un exemple, entrez "atk" dans l'input et cliquez sur des resultats
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ $l=$_GET["l"]; echo "<u>valeur id ".$l."</u><br><br>";
http://test.couvercelle.eu
Partager