...Building a Basic Web Page and More......

A JavaScript Searchable Database
My original introduction to Web site design was a request to produce a catalogue. Hours of research and trawling the web produced many examples but none as good as this one - a script which will allow you to set up a searchable database of your own site. If you haven't used NipperSoft's search engine yet, use this link. Try it and see if you like it as much as I do. It accepts multiple words, is non-case sensitive and acts much like your usual web search engine.
(Many thanks to its author, Satadip Dutta and to Joe Burns, HtmlGoodies)


Before you dive in, grab and use the script, the author asks you to respect these few requirements. This is only understandable and they really are extremely reasonable!
  • Keep the copyright comments in place.
  • Do not alter the script except to add your pages to search.
  • If you are a non-profit site, you may use the script as long as you keep the copyright comments in tact.
  • If you are a for-profit site, you must first ask the author's permission.
Reasonable or what!

Next point:
You must get the entire script and it is quite big. If you download it and it doesn't run - it is either your browser, the download or the use of margins when you edited it.

Another next point:
JavaScript must be in the same shape when it is posted to your site as when you acquired it - if it isn't then it won't work. ALWAYS edit the scripts in an editor without margins, like NotePad.

Tip:
Fix one error at a time - earliest error first, it may be the one causing all the rest!

OK - Click here for the Database Script - jsdatabase.txt


Now that you have the script, you will need to change one or two things and add your pages to the script. I'll start at the top and work down the script. After the copyright description, find a short line that reads:
title [0] = 6
The number, in this case 6, refers to the number of pages that have been added to the database. This number must be changed to the number of pages that you add. You can do this when you have finished adding your pages. But don't forget to do it. If you don't only the first six will be searched!

Now, just below this line is a comment line <!--Begin List of Searchable Items -->. This is where you begin to replace and add your pages. Below the comment line you will see groupings:
title [1]="yahoo search engine"
desc [1]= "The Yahoo Search Engine"
links [1]="http://www.yahoo.com"
matched [1]=0
You need to add and/or alter each one of these groupings for every page you want the script to search.
  • title [1] = "yahoo search engine" - the words inside the quotation marks are the words the script searches. Separate the words you put in with a space. These are the searched items. There is no limit to the number of words but the more you use - the longer it takes to load and search.
  • desc [1]= "The Yahoo Search Engine" - this is the description that appears in the results page.
  • links [1]= "http://www.yahoo.com" - this is the link that is offered - external or one of your own pages.
  • matched [1]= 0 - ONLY change the number in the square brackets [ ].
Make sure that each grouping has the same number and increase it for each subsequent grouping. The first group of four all get number [1]. The second group get number [2] etc. If you don't - you will get a lot of errors - one for each page out of order.

When you have finished adding your pages, remember to go back and change the title [0] = 6 line. Replace the number 6 with the number of pages you have added. If you don't, only the first six will be searched.

Last but not least, look for the comment line - //prepare for document write. - towards the bottom of the script.
Below this look for output.document.write('<title>Goodies Search Results </title>'); change the name to that of your Search Result title.
This title will appear in the search results Window title bar (the blue bar at the top).

Finally, just below this line is a similar one. Change this to reflect the name of your Search Results. This will appear as the heading in the Search Results Table.

That's it folks.   Remember the requirements and edit all this in NotePad. Add it to your page ( copy and paste in NotePad ) between </HEAD> and <BODY>.
Give thanks to Satadip Dutta and Joe Burns. Best of luck - ain't it brill!


 Java ScriptTop of Page 

Copyright © 2000-2006 NipperSoft