Click to See Complete Forum and Search --> : Search Script Lowercase Only :(


96turnerri
11-11-2003, 07:20 AM
hi i have found this script and edited it which searchs pages i enter using js, if i searched for home, home page would come up in the search results, but if i search for HOME or Home nothing comes up, even if i add HOME and Home to the keywords it still doesnt return the homepage

I have tried using a script that changes a tb value into lowercase but the whole thing doesnt work then and heres the script i used for that

<input type="text" onChange="javascript:this.value=this.value.toLowerCase();">

this works on its on but not with the search script heres the search script

<script language="JavaScript" text="text/javascript">
var item = new Array();
// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"

c=0; item[c]=new Array("pagename","","page title","key words");
c++; item[c]=new Array("pagename","","page title","key words");
c++; item[c]=new Array("pagename","","page title","key words");
c++; item[c]=new Array("pagename","","page title","key words");
c++; item[c]=new Array("pagename","","page title","key words");

page="<html><head><title>Search Results</title><link rel=stylesheet href=emx_nav_right.css type=text/css></head><body><div id=pagecell1><!--pagecell1--><img alt=curve src=tl_curve_white.gif height=6 width=6 id=tl><img alt=curve src=tr_curve_white.gif height=6 width=6 id=tr><div id=breadCrumb><u><a href=home.htm target=_blank>Home</a></u> / <u><strong>Search Results</strong></u></div><div id=pageName><h2>Search Results</h2></div><div id=pageNav><div id=sectionLinks><a href=home.htm target=_blank>Home</a><a href=abrasives.htm target=_blank>Abrasives</a><a href=cmaterials.htm target=_blank>Cleaning Materials</a><a href=consumables.htm target=_blank>Consumables</a><a href=fastenings.htm target=_blank>Fastenings</a><a href=lubrication.htm target=_blank>Lubrication</a><a href=protective.htm target=_blank>Protective</a><a href=tools.htm target=_blank>Tools</a></div><p align=center><strong>Stockists Of</strong><br><br><img src=draper.gif alt=Draper Logo><br><br><img src=jsealey.gif alt=Jack Sealey Logo><br><br><img src=ryobi.gif alt=Ryobi Logo><br><br><img src=hitachi.gif alt=Hitachi Logo><br><br><img src=stanley.gif alt=Stanley Logo><br><br><img src=record.gif alt=Record Logo><br><br><img src=teng.jpg alt=Teng Logo><br><br><img src=demo.gif alt=Demo><br><br></p></div><div id=content><div class=feature><table border=0 cellspacing=10 width=100%>";

function search(frm) {
win = window.open("","","scrollbars,resizable,menubar,status,location,toolbar");
win.document.write(page);
txt = frm.searchFor.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.document.write("</table><br>Total found: "+total+"<br><a href=javascript:window.close()>Close Window</a></div></div></body></html>");
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0];
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Score: "+num+"<br>";
line += item[which][4] + "<br>"+link+"</td></tr>";
wind.document.write(line);
return 1;
}
// End -->
</script>

<form method="get" id="search" action="javascript:void(0)" onsubmit="search(this); return false;">
<input name="searchFor" value="Search For.." type="text" size="15" onFocus="if(this.value=='Search For..')this.value='';">
<input name="Submit" type="submit" value="Search!">
</form>

it would be a great help if someone could show me what im doing wrong

Thanks
Rich

p.s. also i cant get the results to open up in the current window the open up in a new one, any ideas on that thanks alot

:D

96turnerri
11-11-2003, 11:40 AM
ive kinda fixed the searching in lower case, by adding alternate ways of type the words such as home,HOME,Home but if any1 else knows a way to fix it another easier way, help would be appreciated

still remains orignal problem aswell how can i get it to open in current window :confused:

Thanks
Rich