Click to See Complete Forum and Search --> : What could I be doing wrong here?


jeff9800
03-02-2003, 10:49 AM
i made a template and a a page off a template that i have a search sesults on. I have the rearch field on the template and when you search it only work when you are on that search.html page here is the code i have:


ON TEMPLATE:

<FORM NAME="searchengine" onSubmit="return search()">
If you are looking for anything just search

<INPUT NAME="keywords" TYPE="text" VALUE="" size="10" MAXLENGTH=20>
<INPUT TYPE="SUBMIT" NAME="go" VALUE="Search">
</FORM>


ON RESULTS PAGE:


<!-- This is for netscape, don't mess with it.... -->
<style>#SEARCHOUT { visibility:show; position:relative;}</style>

<!-- Put this DIV where you want the search results to show up after a search is performed. -->

<DIV ID="SEARCHOUT"></DIV>


Any ideas on how to make it work when your on ANY page on the site?

Thanks!!


Jeff
wolfpack333@hotmail.com

pyro
03-02-2003, 11:09 AM
You will probably need to include your javascript function search() on each page.

jeff9800
03-02-2003, 11:14 AM
its pulling it from this:



ttl = new Object();
desc = new Object();
keys = new Object();
links= new Object();
matched= new Object();
kwords= new Object();
found= new Object();
temp=0;
kwords[0]=0;
found[0]=0;
output = '';

function search() {

temp=0;
kwords[0]=0;
found[0]=0;
output = '';
do_search();
show_output();


return false;
}


function do_search(){

var skeyword=document.searchengine.keywords.value.toLowerCase();
var check=1;
var pos=0;
var i=0;
var j=0;
var itemp=0;
var config='';

while (true) {
if (skeyword.indexOf("+") == -1 ) {
kwords[check]=skeyword;
break;
}
pos=skeyword.indexOf("+");
if (skeyword !="+") {
kwords[check]=skeyword.substring(0,pos);
check++;
}
else {
check--;
break;
}
skeyword=skeyword.substring(pos+1, skeyword.length);
if (skeyword.length ==0) {
check--;
break;
}

}

// the keywords have been put in keywords object.
kwords[0]=check;

// matching and storing the matches in matched
for ( i=1; i<=kwords[0];i++) {
for (j=1;j<=num_titles;j++) {
if ( keys[j].toLowerCase().indexOf(kwords[i]) > -1 || ttl[j].toLowerCase().indexOf(kwords[i]) > -1 || desc[j].toLowerCase().indexOf(kwords[i]) > -1) {
matched[j]++;
}
}
}


// putting all the indexes of the matched records in found
for (i=1;i<=num_titles;i++) {
if (matched[i] > 0 ) {
found[0]++;
// increment the found
found[found[0]]=i;
}
}



for (i=1;i<=found[0]-1;i++) {
for(j=i+1;j<=found[0];j++) {
if ( matched[found[i]]< matched[found[j]] ) {
temp= found[j];
found[j]=found[i];
found[i]=temp;
}
}
}

// end of sort

// SEARCH HEADER //
output = output + 'Search Results for: <B>';
for (i=1; i<=kwords[0]; i++) {
output = output + kwords[i].bold() + " ";
}
output = output + '</B>';

// No Results //
if (found[0]==0) {
output = output + "<HR><BR><BR><b>No matches resulted in this search </b> <br>";
output = output + "You may close the results and reduce the length/number of the keywords <br>";
}

// Results Found //
else {

output = output + "[" + found[0] + " Matches " . italics();
output = output + "]<HR><BR><OL>";

for (i=1; i<=found[0];i++) {
output = output + "<LI>";
itemp=found[i];
output = output + ttl[itemp].bold() + "<br>";
output = output + desc[itemp] + "<br>";
output = output + links[itemp].link(links[itemp])+"<br>";
temp= (matched[itemp]/kwords[0])*100
output = output + "<i>" +temp+" % </i><P>" ;
matched[itemp]=0
}
found[0]=0;
output = output + "</OL>";
}

}

function show_output() {

var NS4 = (document.layers) ? 1 : 0;
var IE = (document.all) ? 1 : 0;
var DOM = 0;
var Opera = 0;

if (parseInt(navigator.appVersion) >=5) {DOM=1};

if ( (navigator.userAgent.indexOf("Opera 6")!=-1) || (navigator.userAgent.indexOf("Opera/6")!=-1) ) {
DOM = 0;
IE = 0;
Opera = 1;
}

target=('SEARCHOUT');

if (DOM || IE) {
var out = document.getElementById(target);
out.innerHTML = output;
}

else if (NS4 || Opera) {
config='height=400,width=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=y es,resizable=yes'
win = window.open ("","outputwindow",config)
win.document.open();
win.document.write(output);
win.document.close();
}

// && (version >=4)
else {
alert("get a real browser");
}


}




--------------------

Thats the search... heres is the search stuff it pulls:

--------------


num_titles = 64
ttl[1] = ' Honky Tonk Man - Sept. 1987 WWF Magazine'
links[1] = 'http://www.wrestlewarehouse.com/wwf1987mags.html'
desc[1] = ' '
keys[1] = 'magazine, honky tonk man, Bam Bam Bigelow, september'
matched[1]=0

ttl[2] = ' Elizabeth - May 1988 WWF Magazine'
links[2] = 'http://www.yahoo.html'
desc[2] = ' '
keys[2] = 'bam bam, bret hart, bobby heenan, elizabeth, magazine'
matched[2]=0

pyro
03-02-2003, 11:22 AM
I'm not exactly sure what it is you need to know...I think for this to work on all your pages, you need to:
1. Include this code (the javascript) on all your pages
or
2. Include the code as an external .js file.

jeff9800
03-02-2003, 01:08 PM
i added the search code to all pages and it just refreshes the page:
there is the code i added
www.wrestlewarehouse.com/index2.html




ttl = new Object();
desc = new Object();
keys = new Object();
links= new Object();
matched= new Object();
kwords= new Object();
found= new Object();
temp=0;
kwords[0]=0;
found[0]=0;
output = '';

function search() {

temp=0;
kwords[0]=0;
found[0]=0;
output = '';
do_search();
show_output();


return false;
}


function do_search(){

var skeyword=document.searchengine.keywords.value.toLowerCase();
var check=1;
var pos=0;
var i=0;
var j=0;
var itemp=0;
var config='';

while (true) {
if (skeyword.indexOf("+") == -1 ) {
kwords[check]=skeyword;
break;
}
pos=skeyword.indexOf("+");
if (skeyword !="+") {
kwords[check]=skeyword.substring(0,pos);
check++;
}
else {
check--;
break;
}
skeyword=skeyword.substring(pos+1, skeyword.length);
if (skeyword.length ==0) {
check--;
break;
}

}

// the keywords have been put in keywords object.
kwords[0]=check;

// matching and storing the matches in matched
for ( i=1; i<=kwords[0];i++) {
for (j=1;j<=num_titles;j++) {
if ( keys[j].toLowerCase().indexOf(kwords[i]) > -1 || ttl[j].toLowerCase().indexOf(kwords[i]) > -1 || desc[j].toLowerCase().indexOf(kwords[i]) > -1) {
matched[j]++;
}
}
}


// putting all the indexes of the matched records in found
for (i=1;i<=num_titles;i++) {
if (matched[i] > 0 ) {
found[0]++;
// increment the found
found[found[0]]=i;
}
}



for (i=1;i<=found[0]-1;i++) {
for(j=i+1;j<=found[0];j++) {
if ( matched[found[i]]< matched[found[j]] ) {
temp= found[j];
found[j]=found[i];
found[i]=temp;
}
}
}

// end of sort

// SEARCH HEADER //
output = output + 'Search Results for: <B>';
for (i=1; i<=kwords[0]; i++) {
output = output + kwords[i].bold() + " ";
}
output = output + '</B>';

// No Results //
if (found[0]==0) {
output = output + "<HR><BR><BR><b>No matches resulted in this search </b> <br>";
output = output + "You may close the results and reduce the length/number of the keywords <br>";
}

// Results Found //
else {

output = output + "[" + found[0] + " Matches " . italics();
output = output + "]<HR><BR><OL>";

for (i=1; i<=found[0];i++) {
output = output + "<LI>";
itemp=found[i];
output = output + ttl[itemp].bold() + "<br>";
output = output + desc[itemp] + "<br>";
output = output + links[itemp].link(links[itemp])+"<br>";
temp= (matched[itemp]/kwords[0])*100
output = output + "<i>" +temp+" % </i><P>" ;
matched[itemp]=0
}
found[0]=0;
output = output + "</OL>";
}

}

function show_output() {

var NS4 = (document.layers) ? 1 : 0;
var IE = (document.all) ? 1 : 0;
var DOM = 0;
var Opera = 0;

if (parseInt(navigator.appVersion) >=5) {DOM=1};

if ( (navigator.userAgent.indexOf("Opera 6")!=-1) || (navigator.userAgent.indexOf("Opera/6")!=-1) ) {
DOM = 0;
IE = 0;
Opera = 1;
}

target=('SEARCHOUT');

if (DOM || IE) {
var out = document.getElementById(target);
out.innerHTML = output;
}

else if (NS4 || Opera) {
config='height=400,width=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=y es,resizable=yes'
win = window.open ("","outputwindow",config)
win.document.open();
win.document.write(output);
win.document.close();
}

// && (version >=4)
else {
alert("get a real browser");
}

jeff9800
03-02-2003, 01:14 PM
i added the search code to all pages and it just refreshes the page:
there is the code i added
www.wrestlewarehouse.com/index2.html




ttl = new Object();
desc = new Object();
keys = new Object();
links= new Object();
matched= new Object();
kwords= new Object();
found= new Object();
temp=0;
kwords[0]=0;
found[0]=0;
output = '';

function search() {

temp=0;
kwords[0]=0;
found[0]=0;
output = '';
do_search();
show_output();


return false;
}


function do_search(){

var skeyword=document.searchengine.keywords.value.toLowerCase();
var check=1;
var pos=0;
var i=0;
var j=0;
var itemp=0;
var config='';

while (true) {
if (skeyword.indexOf("+") == -1 ) {
kwords[check]=skeyword;
break;
}
pos=skeyword.indexOf("+");
if (skeyword !="+") {
kwords[check]=skeyword.substring(0,pos);
check++;
}
else {
check--;
break;
}
skeyword=skeyword.substring(pos+1, skeyword.length);
if (skeyword.length ==0) {
check--;
break;
}

}

// the keywords have been put in keywords object.
kwords[0]=check;

// matching and storing the matches in matched
for ( i=1; i<=kwords[0];i++) {
for (j=1;j<=num_titles;j++) {
if ( keys[j].toLowerCase().indexOf(kwords[i]) > -1 || ttl[j].toLowerCase().indexOf(kwords[i]) > -1 || desc[j].toLowerCase().indexOf(kwords[i]) > -1) {
matched[j]++;
}
}
}


// putting all the indexes of the matched records in found
for (i=1;i<=num_titles;i++) {
if (matched[i] > 0 ) {
found[0]++;
// increment the found
found[found[0]]=i;
}
}



for (i=1;i<=found[0]-1;i++) {
for(j=i+1;j<=found[0];j++) {
if ( matched[found[i]]< matched[found[j]] ) {
temp= found[j];
found[j]=found[i];
found[i]=temp;
}
}
}

// end of sort

// SEARCH HEADER //
output = output + 'Search Results for: <B>';
for (i=1; i<=kwords[0]; i++) {
output = output + kwords[i].bold() + " ";
}
output = output + '</B>';

// No Results //
if (found[0]==0) {
output = output + "<HR><BR><BR><b>No matches resulted in this search </b> <br>";
output = output + "You may close the results and reduce the length/number of the keywords <br>";
}

// Results Found //
else {

output = output + "[" + found[0] + " Matches " . italics();
output = output + "]<HR><BR><OL>";

for (i=1; i<=found[0];i++) {
output = output + "<LI>";
itemp=found[i];
output = output + ttl[itemp].bold() + "<br>";
output = output + desc[itemp] + "<br>";
output = output + links[itemp].link(links[itemp])+"<br>";
temp= (matched[itemp]/kwords[0])*100
output = output + "<i>" +temp+" % </i><P>" ;
matched[itemp]=0
}
found[0]=0;
output = output + "</OL>";
}

}

function show_output() {

var NS4 = (document.layers) ? 1 : 0;
var IE = (document.all) ? 1 : 0;
var DOM = 0;
var Opera = 0;

if (parseInt(navigator.appVersion) >=5) {DOM=1};

if ( (navigator.userAgent.indexOf("Opera 6")!=-1) || (navigator.userAgent.indexOf("Opera/6")!=-1) ) {
DOM = 0;
IE = 0;
Opera = 1;
}

target=('SEARCHOUT');

if (DOM || IE) {
var out = document.getElementById(target);
out.innerHTML = output;
}

else if (NS4 || Opera) {
config='height=400,width=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=y es,resizable=yes'
win = window.open ("","outputwindow",config)
win.document.open();
win.document.write(output);
win.document.close();
}

// && (version >=4)
else {
alert("get a real browser");
}