Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/02/2008, 15:07
paco08
 
Fecha de Ingreso: febrero-2008
Mensajes: 4
Antigüedad: 16 años, 3 meses
Puntos: 0
Sonrisa Re: Ayuda, sobre codigo de buscador interno

Muchas gracias KarlanKas, me salvaste la vida, el codigo funcionó muy bien, y me muestra los resultados en la misma página, yo sufri tratando de hacer eso y no pude, y tu en un segundo lo lograste.

Gracias y Saludos!!!


Cita:
Iniciado por KarlanKas Ver Mensaje
A ver si así funciona:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!---aqui comienza el buscador -->
<script language="JavaScript">
<!-- Begin
var item = new Array();

// "Nombre de la página","Situación página","Título","Palabras clave","Comentarios descriptivos"

/* links below were changed so a 404 error would not be found if someone actually clicked them in the www.js-examples.com database */
c=0; item[c]=new Array("http://www.imperiomusica.com/hilaryduff.php","","hilary","duff","hilaryduff","H ILARY DUFF", "HILARY", "DUFF","Hilary Duff");
c++; item[c]=new Array("http://www.topmusik.ya.st/","","topmusik","musik,top,mu","Topmusik");


codigo="<h1>Search Results</h1><table border=0 cellspacing=10 width=80%>";

function search(frm) {
win = document.getElementById("resultado");
win.innerHTML=codigo;
txt = frm.srchval.value.split(" ");
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, win, n);
fnd[w] = 0;
}
win.innerHTML+="</table><center><br><font size=2>Tu busqueda se ha encontrado:"+total+"<br></body></html></font>";
win.innerHTML+="<hr></table><center><br><b><font size=4><big>ImperioMusica.com<br></font><font size=2></head></html></font>";
win.innerHTML+="</table><head><center><br><font size=2>El imperio de la música ha llegado<br></head></html>";

}
function show(which,wind) {
link = item[which][1] + item[which][0];
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a><br>";
line += item[which][4] ;
wind.innerHTML+=line;

return 1;
}
// End -->
</script>

</font></font></font></font></font><form method="get" action="javascript:void(0)" onsubmit="search(this); return false;">


<center><font size="2"><font size="2"><font color=" #66666"><font size="2"><font color=" #66666"><input name="srchval" value="" size="20" type="text"><input value="BUSCAR" type="submit">
<div id="resultado"></div>
<br>

<!-- fin del buscador -->
Debes crear una capa con id = "resultado" y la pones justo debajo del buscador:

<div id="resultado"></div>


O con el id que quieras ponerle, pero tienes que referenciarlo en la definición de win:

win = document.getElementById("resultado");

Espero que funcione!