Bonsoir a tous,
voila je suis en train de faire un petit site web en php, et j'ai fais appel a javascript pour faire un system de suggestion, le problem c que j'utilise deux fonctions identique mais chaqu'une pour un champ particulier, et sa me crée un conflit entre les deux, je sui sur que j'ai un problem dans mon script javascript (je suis pas calé en javascript), voila mon script, j'espere que vous pouvez m'aidé, merci a tous.
/*-----------------suggestion-produit-------------*/
function suggest_produit(inputString){
if(inputString.length == 0) {
$('#suggestions_produit').fadeOut();
} else {
$('#ref_produit').addClass('load');
$.post("autosuggest_produit.php", {queryString: ""+inputString+""}, function(data){
if(data.length >0) {
$('#suggestions_produit').fadeIn();
$('#suggestionsList_produit').html(data);
$('#ref_produit').removeClass('load');
}
});
}
}
//------------------------Info_produit----------------
function afficher_produit(str)
{
if (str=="")
{
document.getElementById("affichage_produit").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("affichage_produit").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","info_produit.php?q="+str,true);
xmlhttp.send();
}
/*-----------------suggestion-client-------------*/
function suggest_client(inputString){
if(inputString.length == 0) {
$('#suggestions_client').fadeOut();
} else {
$('#ref_client').addClass('load');
$.post("autosuggest_client.php", {queryString: ""+inputString+""}, function(data){
if(data.length >0) {
$('#suggestions_client').fadeIn();
$('#suggestionsList_client').html(data);
$('#ref_client').removeClass('load');
}
});
}
}
function fill(thisValue) {
$('#ref_client').val(thisValue);
setTimeout("$('#suggestions_client').fadeOut();",50);
}
//------------------------Info_client----------------
function afficher_client(str2)
{
if (str2=="")
{
document.getElementById("affichage_client").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("affichage_client").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","info_client.php?q="+str2,true);
xmlhttp.send();
}
Afficher la suite