views:

144

answers:

4

I really want to learn how to make my own search engine for my site. I have the defined buttons and labels, but it doesn't search. I can't figure out the HTML or XHTML code for actually searching the site.

This is the code I have so far:

<p class="search">
    <label>SEARCH</label>
    <input name="search" type="text" class="txt" />
    <input name="search-btn" type="submit" class="btn" value="SEARCH" />
</p>

Thanks!

+3  A: 

You cannot provide a search function with just HTML and XHTML, unless you're just using a standardized form to get some external search engine (like Google) to do the work.

It is possible to do search with JavaScript, but that requires you to transfer all the data to the client, so it is not a very good idea.

If you want to write it yourself, you should use some server-side language, such as PHP or Python - it depends on what you have access to.

Michael Madsen
+3  A: 

Check out Google Site Search.

Jim Lamb
A: 

Adding search to your site isn't nearly as simple as creating a search form: it also involves a bunch of programming. Depending on your experience level and what you are trying to do, it can be fun and rewarding to program simple search functionality to your site, but it can also be extremely time-consuming. If you want to take the easy route, use http://www.google.com/sitesearch/ as Jim suggested. If you want to make it yourself, see something like http://stackoverflow.com/questions/386914/how-would-i-implement-a-simple-site-search-with-php-and-mysql to get started.

Mike Comstock
thanks guysyeah...i see how you have to use javascript...thanks again
felixd68
Note that if you use google site search (or any other external provider), getting results back depends on being indexed by google in the first place - something small sites often find doesn't happen as quickly/comprehensively as they'd like.
adam
+1  A: 

There is no feature in HTML that will perform the search. But you do have 3 alternative options:

  1. You can integrate 3rd-party search engines like Google into your site. (Or see one of these examples.)
  2. You can upload a CGI page which uses PHP, Perl, or another scripting language to perform the local search for you.
  3. Lastly, there are some options for JavaScript search engines which work right inside the page.
ewall