OnkeyUp ne fonctionne pas
bgmis
Messages postés
7
Date d'inscription
Statut
Membre
Dernière intervention
-
bgmis Messages postés 7 Date d'inscription Statut Membre Dernière intervention -
bgmis Messages postés 7 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'utilise une fonction xajax qui affiche des données dans un tableau. Pour l'appel j'utilise l'évènement onkeyup dans le champ de texte de mon formulaire. Le problème c'est que pour 1,2,3 caractères cela ne marche pas (le curseur ne fait que tourner) mais lorsqu'on continu la saise à 4,5 caractères et plus la fonction marche parfaitement et affiche mes données. J'ai tout tenté (utilisation de onchange, onkeydown et des test sur ma fonction) mais en vain. Je souligne que le disfonctionnement est valable pour IE comme Mozilla firefox; Merci de m'aider car cela fait un bon moment que je cherche
j'utilise une fonction xajax qui affiche des données dans un tableau. Pour l'appel j'utilise l'évènement onkeyup dans le champ de texte de mon formulaire. Le problème c'est que pour 1,2,3 caractères cela ne marche pas (le curseur ne fait que tourner) mais lorsqu'on continu la saise à 4,5 caractères et plus la fonction marche parfaitement et affiche mes données. J'ai tout tenté (utilisation de onchange, onkeydown et des test sur ma fonction) mais en vain. Je souligne que le disfonctionnement est valable pour IE comme Mozilla firefox; Merci de m'aider car cela fait un bon moment que je cherche
3 réponses
<?php require_once('../Connections/connexion.php'); if (isset($_GET['test'])) $payss=$_GET['test']; else $payss="0"; #connexion à la BD $connexion = mysql_connect($hostname_connexion, $username_connexion, $password_connexion); #Sélection de la BD mysql_select_db($database_connexion, $connexion); // Fonction qui affiche les entreprises en fonction du texte saisie : function AfficheEntreprise($valeure,$status,$paysss) { $reponse = new xajaxResponse();// Création d'une instance de xajaxResponse //création du tableau if ($status=="") { if ($paysss==0){ $sql="SELECT DISTINCT entreprise.mat_entreprise, entreprise.situation_actuelle, entreprise.raison_sociale, entreprise.sigle, entreprise.adresse, entreprise.telephone1, entreprise.telephone2, entreprise.code_pays, entreprise.url_site, entreprise.email, entreprise.fax, entreprise.observation, entreprise.situation_geographique, pays.intitule_pays FROM entreprise, pays WHERE entreprise.code_pays=pays.code_pays AND (entreprise.sigle LIKE \"%$valeure%\" OR entreprise.raison_sociale LIKE \"%$valeure%\") AND entreprise.situation_actuelle='active'"; } else { $sql="SELECT DISTINCT entreprise.mat_entreprise, entreprise.situation_actuelle, entreprise.raison_sociale, entreprise.sigle, entreprise.adresse, entreprise.telephone1, entreprise.telephone2, entreprise.code_pays, entreprise.url_site, entreprise.email, entreprise.fax, entreprise.observation, entreprise.situation_geographique, pays.intitule_pays FROM entreprise, pays WHERE entreprise.code_pays=pays.code_pays AND entreprise.code_pays='$paysss' AND (entreprise.sigle LIKE \"%$valeure%\" OR entreprise.raison_sociale LIKE \"%$valeure%\") AND entreprise.situation_actuelle='active'"; } } else { if ($paysss==0){ $sql="SELECT DISTINCT entreprise.mat_entreprise, entreprise.situation_actuelle, entreprise.raison_sociale, entreprise.sigle, entreprise.adresse, entreprise.telephone1, entreprise.telephone2, entreprise.code_pays, entreprise.url_site, entreprise.email, entreprise.fax, entreprise.observation, entreprise.situation_geographique, pays.intitule_pays FROM entreprise, pays WHERE entreprise.code_pays=pays.code_pays AND (entreprise.sigle LIKE \"%$valeure%\" OR entreprise.raison_sociale LIKE \"%$valeure%\")"; } else { $sql="SELECT DISTINCT entreprise.mat_entreprise, entreprise.situation_actuelle, entreprise.raison_sociale, entreprise.sigle, entreprise.adresse, entreprise.telephone1, entreprise.telephone2, entreprise.code_pays, entreprise.url_site, entreprise.email, entreprise.fax, entreprise.observation, entreprise.situation_geographique, pays.intitule_pays FROM entreprise, pays WHERE entreprise.code_pays=pays.code_pays AND entreprise.code_pays='$paysss' AND (entreprise.sigle LIKE \"%$valeure%\" OR entreprise.raison_sociale LIKE \"%$valeure%\")"; } } /////////////////////////////////////////////////////// $query = mysql_query($sql) or die (mysql_error()); $nbr=mysql_num_rows($query); $j=0; $nbr='<div id="nbreEntr" style="font-size:14px; text-align:left; color:#F00; font-family:Verdana, Geneva, sans-serif">Nombre d\'entreprises: '.$nbr.'</div>'; $valeur = $nbr.'<table id="listeEntreprise" border=1 cellspacing=0 class="affich" > <thead> <tr> <th width="10%">Matricule</th> <th width="25%">Raison Sociale</th> <th width="10%">Sigle</th> <th width="15%">Adresse et Fax</th> <th width="10%">Site et Email</th> <th width="10%">Contacts</th> <th width="10%">Situation Géographique</th> <th width="10%">Pays</th> </tr> </thead>'; $valeur.="<tbody>"; while ($row = mysql_fetch_assoc($query)) { $mat_entreprise=trim($row['mat_entreprise']); $raison_sociale=htmlentities(trim($row['raison_sociale']), ENT_QUOTES); $sigle=htmlentities(trim($row['sigle']), ENT_QUOTES); $adr_fax='Adresse: '.htmlentities(trim($row['adresse']), ENT_QUOTES); $adr_fax.='<br/>Fax: '.htmlentities(trim($row['fax']), ENT_QUOTES); $contact='Contact1: '.trim($row['telephone1']); $contact.='<br/>Contact2 :'.trim($row['telephone2']); $sitemail='Site Web: '.htmlentities(trim($row['url_site']), ENT_QUOTES); $sitemail.='<br/>Email: '.htmlentities(trim($row['email']), ENT_QUOTES); $sitgeo=htmlentities(trim($row['situation_geographique']), ENT_QUOTES); if (!empty($row['intitule_pays'])) $pay=htmlentities(trim($row['intitule_pays']), ENT_QUOTES); //$valeur.='<tr class="row1"><td>'.$mat_entreprise.'</td><td>'.$raison_sociale.'</td><td>'.$sigle.'</td><td>'.$adr_fax.'</td><td>'.$sitemail.'</td><td>'.$contact.'</td><td>'.$sitgeo.'</td><td>'.$pay.'</td></tr>'; //cas 1 : l'entreprise est active alors on cherche dans la table produits_decision toutes ses décisions if ($j % 2 == 0){ $valeur.="<tr class=\"row1\"><td>$mat_entreprise</td><td>$raison_sociale</td><td>$sigle</td><td>$adr_fax</td><td>$sitemail</td><td>$contact</td><td>$sitgeo</td><td>$pay</td></tr>"; } else {$valeur.="<tr><td>$mat_entreprise</td><td>$raison_sociale</td><td>$sigle</td><td>$adr_fax</td><td>$sitemail</td><td>$contact</td><td>$sitgeo</td><td>$pay</td></tr>";} $j++; } $valeur.='</tbody></table>'; $reponse->assign('resultat', 'innerHTML', $valeur); return $reponse; } ############### le formulaire <form name="formdec" method="post" action=""> <table width="100%" border="0"> <tr> <td width="16%" align="right">Entreprise: </td> <td width="20%"><input type="text" name="nomentreprise" id="nomentreprise" size="40" onkeyup="<?php echo 'xajax_AfficheEntreprise(document.getElementById(\'nomentreprise\').value,formdec.ferm.checked,\''.$payss.'\');'; ?>" /></td> <td width="64%">Inclure les Entreprises Fermées : <input name="ferm" id="ferm" type="checkbox" onclick="<?php echo 'xajax_AfficheEntreprise(document.getElementById(\'nomentreprise\').value,formdec.ferm.checked,\''.$payss.'\');'; ?>" /></td> </tr> </table></form>