home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2000 September / PCpro_2000_09.ISO / webdesign / training / kakao / tips / search_tips.js < prev    next >
Encoding:
Text File  |  1999-02-20  |  1.9 KB  |  73 lines

  1. function MakeArray(n) {
  2.         this.length=n;
  3.         for (var i=1; i<=n; i++) {
  4.                 this[i]="";
  5.         }
  6.         return this;
  7. }
  8.  
  9. var MaxLinks = 40;
  10.  
  11. url      = new MakeArray(MaxLinks);
  12. keywords = new MakeArray(MaxLinks);
  13. test     = new MakeArray(MaxLinks);
  14. matches  = new MakeArray(MaxLinks);
  15. var nmatches   = 0;
  16.  
  17. var goto_url   = "search_find.html";
  18. var goto_frame = "inhalt";
  19.  
  20. /**********************************************************************/
  21.  
  22. url[1]          = "http://javascript.seite.net";
  23. keywords[1]     = "Textbox, Formulare, Information";
  24. test[1]     = "Textboxnformation";
  25.  
  26.  
  27.  
  28.  
  29. /**********************************************************************/
  30.  
  31. function searchKeywords(i,keywords) {
  32.  
  33.         var this_keyword
  34.         var end = keywords.indexOf(",");
  35.  
  36.         if (end != -1) {
  37.                 this_keyword = keywords.substring(0,end);
  38.                 keywords = keywords.substring((end+1),keywords.length);
  39.         }
  40.         else {
  41.                 this_keyword = keywords;
  42.                 keywords = "";
  43.         }
  44.  
  45.         var temp = document.form.query.value.toLowerCase();
  46.  
  47.         if (this_keyword.toLowerCase().indexOf(temp) >= 0) {
  48.                 matches[nmatches] = url[i] + "+" + this_keyword;
  49.                 nmatches++;
  50.         }
  51.  
  52.         if (end != -1) searchKeywords(i,keywords);
  53. }
  54.  
  55. function processSearch() {
  56.  
  57.         var query = document.form.query.value;
  58.  
  59.         parent.frames[1].store = "?" + query;
  60.  
  61.         if (query == "") alert("\nBitte geben Sie ein Suchwort ein.");
  62.         else {
  63.                 for (var i=1; i<=MaxLinks; i++) {
  64.                         if (keywords[i] != "" && url[i] != "") searchKeywords(i,keywords[i]);
  65.                 }
  66.                 for (var i=0; i<nmatches; i++) {
  67.                         parent.frames[1].store += "&" + escape(matches[i]);
  68.                 }
  69.                 window.open(goto_url,goto_frame);
  70.         }
  71. }
  72.  
  73.