Multi-Search Block.
Written on 02/04/06 at 15:52:12 EST by Jack Deth
Not sure where this originates from.
A User named "eeeprom" on the web-app site asked about it, and I grabbed the code and "app'ed" it.

Here is how to get it going on your site.

Open webapp.js
add in this code to the bottom:

code:
// JavaScript for Search Block
function wordsplit(items)
   {   var charect = "";
         for (var n = 1 ; n <= items.length ; n++)
            {   if (items.substring(n - 1, n) == " ")
            {   charect += "+"; }
         else
   {   charect += items.substring(n - 1, n);
            }
            }
         return charect;
      }

function search()
   {   if (document.searching.query.value != "")
         {   var keywords = document.searching.query.value;   }
      else
      {   
   return
      }
      var searchurl = "";

      key = wordsplit(keywords);
      for (index = 0; index < document.searching.searchEngine.length; index++)
      {
   if (document.searching.searchEngine[index].checked)
   {
      searchurl = document.searching.searchEngine[index].value;
      break;
   }
      }

      searchurl += key;
      if (document.searching.newwind.checked)
      {
   wind = window.open(searchurl, "SearchResults");
      }
      else
      {
   window.location.href = searchurl;
      }
   }
  
function reset()
   {
      searching.query.text = "";
      searching.searchEngine[0].checked = true;
   }
      //-->



Save webapp.js

Now go to Site Admin, Block Administration, Bottom Center Blocks.

Once there make a new block called Search or whatever you want, and drop this 1 line of code into the block.


code:
<CENTER><FORM NAME="searching" ><TABLE WIDTH=400><TR><TD WIDTH=70%>Enter the Keyword : <INPUT TYPE="text" NAME="query" SIZE=20><BR><BR>Select the Search Engine :<br><br><TABLE WIDTH=100%><TR><TD WIDTH=50% VALIGN=TOP ALIGN=LEFT><INPUT TYPE="radio" NAME="searchEngine" VALUE="http://www.google.com/search?q=">Google<br><INPUT TYPE="radio" NAME="searchEngine" VALUE="http://search.yahoo.com/search?p=" CHECKED> Yahoo<br><INPUT TYPE="radio" NAME="searchEngine" VALUE="http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&fmt=.&q=">Altavista<br></TD><TD WIDTH=50% VALIGN=TOP ALIGN=LEFT><INPUT TYPE="radio" NAME="searchEngine" VALUE="http://www.lycos.com/cgi-bin/pursuit?query=">Lycos<br><INPUT TYPE="radio" NAME="searchEngine" VALUE="http://www.metacrawler.com/crawler?general=">Metacrawler<br><INPUT TYPE="radio" NAME="searchEngine" VALUE="http://www.search.com/Infoseek/1,135,0,0200.html?QUERY=">Search.com<br></TD></TR></TABLE></TD></TR></TABLE><TABLE WIDTH=100%><TR><TD><P><INPUT TYPE="checkbox" NAME="newwind" CHECKED>Open in a new window<P><INPUT TYPE="button" VALUE="Search" onClick="search()"><INPUT TYPE="button" VALUE=" Clear " onClick="reset()" onMouseUp="searching.query.focus();"></TD></TR></TABLE></FORM></CENTER>



This code should list on a single line...
Using multiple lines cause excessive spaces which is why code is not good to use in blocks currently.

Thats it, Enjoy the search block.

Update:
There is an issue with the form where if you write in something to search for and hit the enter key, it doesnt work...  This problem does not occur if you click the Search Button.

I am sure a simple change to the form can fix this issue... but for now, I changed the way its written to say "Click here to Search" on the "Search" button.
Should be good for now...

Forums and Comments Brought to you by: www.2xlnt.com - WA
The comments are owned by the poster. We aren't responsible for its content.