Javascript opérateur ET

Fermé
magpie Messages postés 43 Date d'inscription mardi 17 octobre 2006 Statut Membre Dernière intervention 8 février 2012 - 16 déc. 2008 à 20:24
Alain_42 Messages postés 5361 Date d'inscription dimanche 3 février 2008 Statut Membre Dernière intervention 13 février 2017 - 16 déc. 2008 à 21:39
Bonjour,

je voudrai que mon pseudo-moteur de recherche en ET sur plusieurs mots (si plusieurs mots sont saisis).
A l'heure actuelle il me renvoie toutes les pages contenant au moins un des mots.

//c=0; item[c]=new Array("page.htm","_blank","Titre","mots clés",
"Page Principale de mon site web");
Par exemple :

c=0; item[c]=new Array("Page1.htm","_blank", "Présentation",
"page accueil présentation" ,"Page d'accueil");

c=c+1; item[c]=new Array("Page2.htm","_blank","Fiches produit",
"produit fiche page","Accès aux présentation produit");

function search(frm) {

txt = frm.srchval.value.split(" ");
ligne1 = page + "<tr><td><a href='#' onClick='history.back()'>Retour</a></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td><font size=3><B>Pages trouvées pour \"" + txt + "\" :</B>
</font></td></tr>";
document.write(ligne1);
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd[i] = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };

if (w > -1) total += show(w,n);
fnd[w] = 0;
}

document.write("</table><br>Pages trouvé(s): "+total+"<br>
</font></center></body></html>");

}
function show(which,num) {
link = item[which][0];

line = "<tr><td align='right'><font size=2>" + item[which][4] + " : </td>";

line +=  "<td><a href='"+link+"'>"+item[which][2]+"</a></font></td></tr>";

document.write(line);

return 1;
}


Je ne connais pas Javascript et j'aurai besoin d'un peu d'aide.

Merci.

1 réponse

Alain_42 Messages postés 5361 Date d'inscription dimanche 3 février 2008 Statut Membre Dernière intervention 13 février 2017 894
16 déc. 2008 à 21:39
Pour répondre à ta question titre: ET en js c'est &&

if(condition1 && condition2)
1