Click to See Complete Forum and Search --> : Site Search results load in main window


Dougster2001
02-22-2004, 08:53 PM
I use the site search javascript and i need a way for the search results to load up in the same window as the search form. How should i modify the following code so that the script will not launch a new window to display the search results.

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Dion (biab@iinet.net.au) -->
<!-- Web Site: http://www.iinet.net.au/~biab -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var item = new Array();

/* Here is where all the magic happens.
Just enter as many additional pages that
that you want to search, then fill in the
additional listings for each page.
*/

// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"

c=0; item[c]=new Array("index.htm","","Frontpage, Lattest News,","index,main,start,home,front, news, current events, search function, rfds, fwahs, atsic, urah","The home page of the Maari Ma Website. Has a brief description of Maari Ma services and contains the lattest news.");

c++; item[c]=new Array("HealthCouncil.htm","","Maari Ma Peak Health Council","Maari Ma Peak Health Council The Maari Ma Peak Health Council is the title given to the Maari Ma Board of Directors. Theensures that Maari Ma maintains its focus on community needs.","About Maari Ma Peak Health Council");

c++; item[c]=new Array("background.htm","","Maari Ma Health Background","Maari Ma Health Background Maari Ma Health is aof Maari Ma Health and how it operates");

c++; item[c]=new Array("LowerSectAgree.htm","","The Lower Sector Agreement Between Maari Ma And Far Weat Area Health Service ","The lower sector agreement between maari ma & far west area health service fwahs","");

c++; item[c]=new Array("Map.htm","","Maari Ma Service Area (Map)","map, service area, region, broken hill, tibooburra, white cliffs, wilcannia, menindee, ivanhoe, pooncarie, wentworth, dareton, euston balranald","Map of the region, showing the area Maari Ma Health services");

c++; item[c]=new Array("boarddirectors.htm","","Profiles Of Our Board Of Directors","des jones, maureen o’donnell, gloria king, willy philp, fay johnstone, gloria murray, Councilor"," Page of the board of directors of Maari Ma Health.");

c++; item[c]=new Array("ConatctUs.htm","","Contacts Page","location 1 corporate services, financial department, lower western sector, social emotional well-being service working form the 5th hub, diabetes team chronic illness working from the 5th



function search(frm) {
win = window.open("","","scrollbars");
win.document.write(page);
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.document.write("</table><br>Total found: "+total+"<br></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>