Results 1 to 1 of 1
Related
-
Form output using mysql, search people name in specific category Forum: PHP Forum
Replies: 1 -
links open in new window Forum: HTML Forum
Replies: 8 -
change html-text with a js-function Forum: Javascript Forum
Replies: 1 -
AutoOpen Document in new Window. Forum: PHP Forum
Replies: 2 -
open without new window Forum: Javascript Forum
Replies: 5
-
09-07-2016, 08:53 AM #1
Search function - is it possible to change output = window.open to document.writeln?
Noob here
I found this function online and it works perfectly. It searches for keywords in a text field and shows the results in a new window. What I would like to know is, can i get the output to write to the html page the code is in rather than a new window?
Thanks
HTML Code:function search(){ // get the input from the input by the user and strip it into keywords //+ 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 ) { keywords[check]=skeyword; break; } pos=skeyword.indexOf("+"); if (skeyword !="+") { keywords[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. keywords[0]=check; //alert(check); // matching and storing the matches in matched for ( i=1; i<=keywords[0];i++) { for (j=1;j<=title[0];j++) { if (title[j].toLowerCase().indexOf(keywords[i]) > -1 ) { matched[j]++; } } } // putting all the indexes of the matched records in found for (i=1;i<=title[0];i++) { if (matched[i] > 0 ) { found[0]++; // increment the found found[found[0]]=i; } } //alert("found 0 " + found[0]); // sort the list as per max percentage of matches 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 // prepare for document write. config='toolbar=no,location=no,directories=no,status=no,menubar=no,' config += 'scrollbars=yes,resizable=yes' output = window.open ("","outputwindow",config) output.document.write('<title> Clickipedia Search Results </title>'); output.document.write('<BODY bgcolor=#ffffff text=#000000 link=#990099 vlink =#339966 >'); output.document.write('<center> <h1>Clickipedia Search Results </h1></center>'); output.document.write('<hr>'); output.document.write(' The Keyword(s) you searched :: '.big() ) for (i=1; i<=keywords[0]; i++) { output.document.write( keywords[i].bold() +" "); } output.document.write('<br>'); if (found[0]==0) { //alert(found[0]); output.document.write('<hr>'); output.document.write("<b>No matches resulted in this search </b> <br>"); output.document.write("You may close the results and reduce the length/number of the keywords <br>"); } else { // data has been found output.document.write(" <hr> <b> The Results of the search are : </b> "); output.document.write( found[0] +" Entries found ".italics()); output.document.write("<table border=1 width=100%>"); for (i=1; i<=found[0];i++) { output.document.write("<tr><td valign=top bgcolor=#9999ff>"); output.document.write("<h3>" +i +"</h3>"); output.document.write("<td valign=top>"); itemp=found[i]; output.document.write(desc[itemp].bold() +"<br>" + links[itemp].link(links[itemp])+"<br>"); temp= (matched[itemp]/keywords[0])*100 output.document.write("<i> Matched with keywords :: " +temp+" % </i>" ); matched[itemp]=0 } found[0]=0; output.document.write("</table>"); } output.document.write (); output.document.write ("<hr>"); output.document.write ("<form><center>") output.document.write ("<input type='button' value='Start Another Search' onClick = 'self.close()'>") output.document.write ("</center></form>") }
Need advise on a good hosting provider
04-24-2018, 06:50 AM in Web Hosting Forum