Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search engine

Status
Not open for further replies.

edd1eg

Programmer
Jun 27, 2003
123
GB
Hi there,

How hard would it be to have a search tool within my website?

Would it have to involve using a database?

Is there any good tutorials out there that could help me with this?

thanks

edd
 
Hi there,

How Could you get this code, instead of displaying the results in a pop-up window, displaying in the white space between in line with the (logistics and self-drive hire) in my webpage
<html><HEAD>
<meta name=&quot;AUTHOR&quot; content=&quot;GUJUM0deL (ketan mehta)&quot;>
<meta name=&quot;description&quot; content=&quot;search engine using JS&quot;>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
/*INSTRUCTIONS:
Ok, this is the setup and its quite simple to figure out if you know JS or any other type
of scripting language. First off in the ARRAYs you write in the HTML page, the path of the
site (which can be left blank), a description to what the link is, the keywords entered for
the search criteria, and finaly the description to what the link is about. (IF CONFUSED JUST RUN THE SCRIPT THE WAY IT IS FIRST AND SEE THE RESULTS! OR, JUST EMAIL ME BACK AND I'LL EXPLAIN)
*/
var item = new Array();
Km=0; item[Km]=new Array(&quot;hotmail.com&quot;,&quot; any, free, email, e-mail&quot;,&quot;FREE E-Mails!!&quot;);
Km++; item[Km]=new Array(&quot;Yahoo.com&quot;,&quot; any, yahoo&quot;,&quot;Wanna Yahoo!&quot;);
Km++; item[Km]=new Array(&quot;tvguide.com&quot;,&quot; any, tv, guide, shows&quot;,&quot;TV Guide&quot;);

//YOU CAN EDIT WHAT THE NEW WINDOW WILL LOOK LIKE, SUCH AS TEXT COLOR, BACKGROUND COLOR, LINK COLOR.
pageview=&quot;<html><head><title>Search Results</title></head><body bgcolor='black' text='white' link='#bda940' vlink='#cccccc'><left><table border=0 width=200>&quot;;

function search(formfld) {
//YOU CAN EDIT THE WINDOW PROPERTIES ONLY, NOTHING ELSE.
windw = window.open(&quot;&quot;,&quot;&quot;,&quot;toolbar=no,location=no,directories=no,status=no,menubar=no,height=215,width=250, scrollbars=yes,resizable=no&quot;);
//DO NOT EDIT FROM HERE!!
windw.document.write(pageview);
txt = formfld.searchvalue.value.split(&quot; &quot;);
findingval = new Array(); total=0;
for (i = 0; i < item.length; i++) {
findingval = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[order[j]].indexOf(txt[k].toLowerCase()) > -1 && txt[k] != &quot;&quot;)
findingval += (j+1);
}
for (i = 0; i < findingval.length; i++) {
n = 0; w = -1;
for (j = 0;j < findingval.length; j++)
if (findingval[j] > n) { n = findingval[j]; w = j; };
if (w > -1) total += show(w, windw, n);
findingval[w] = 0;
}
windw.document.write(&quot;</table><br>Total found: &quot;+total+&quot;<br>&quot;);
windw.document.write(&quot;<INPUT onfocus='blur();' type='button' style='background-color:#004080; border-color:#004080; color:#FFFFFF;' value='Close' onClick='self.close()'&quot;);
//PLEASE LEAVE THIS PORTION HERE. IT IS MY AUTHOR'S TAG.
windw.document.write(&quot;<br><br><font size='1'><center>© 2001 by <A HREF=' target='_blank'>GUJUm0deL</A>. All right reserved. </center></font> </body></html>&quot;);

}
/* This function is important. Here you actualy show what the search result window display.
DO NOT EDIT HERE. ONLY EDIT IF YOU KNOW WHAT YOU ARE DOING.
*/
function show(which,dniw,num) {
link = item[which][1] + item[which][0];
//If you want to you can change the 'target' to anything.
line = &quot;<tr><td><a href=&quot;+link+&quot; target='_new'>&quot;+item[which][2]+&quot;</a><br>&quot;;
line += item[which][4] + &quot;<br><br></td></tr>&quot;;
/* By adding this tag: <br>&quot;+link+&quot; between the: + &quot; on the above line you will display the
link in text well.
*/
dniw.document.write(line);
return true;
}
</script>
</HEAD>

<BODY bgcolor=&quot;#000000&quot; text=&quot;bda94c&quot;>
<center>
<!--- leave the 'form method' line the way it is. ALL OF IT -->
<form method=get action=&quot;javascript:void(0)&quot; onsubmit=&quot;search(this); return false;&quot;>
<tr><td>
<p><b><font color=&quot;ff0000&quot;>to see it in action type in:</font> </b></p>
<p>'all' to see all the search results. <i>Without the single quotes.</i><br>
'hotmail' to see the search result for that key word.<br>
You can also enter part of a word and the result will bring back the
entry. <i>Try entering: 'ail' and see what happens.</i><br>
</p>
<p> This script also has the <b>.toLowerCase()</b> so that it convert
all the search words to lowercase. In other words, this script is NOT
case sensitive!! So if you enter in HOTMAIL or hotMAil or hotMAIl,
you still get the right result.</p>
<p><i> Just makes sure that all the keywords are in lowercase in the Array
sction at the top...</i></p>
<p>NS and IE display it differently, <i>BUT IT WORKS IN BOTH BROWSERS!!
</i>For a cooler effect use CSS for the textbox and buttons, like
I did. ( Just a note that NS4 will not display the CSS tags)</p>
<p><b>PLEASE LEAVE MY AUTHORSHIP IN THE SCRIPT THANKS.</b></p>
<p>
<input type=text name=searchvalue value=&quot;&quot;>
<input onFocus='blur();' type=submit value=&quot;Search&quot; style=&quot;background-color:#004080; border-color:#004080; color:#FFFFFF;&quot; name=&quot;Input&quot;>
</p>
</td>
</tr>
</form>
</center>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top