By Christopher Miller
A quick and easy way to add interactivity to your site is to allow your visitors to search the Internet. You can add any search engine to your site as long as they use a query string, here's how.
The first thing you want to do is go to your favorite search engines and grab their query string. You can grab it by simply doping a search. Below is a list of the major search engines and the query strings they use:
The next thing you want to do is to create your page. Lets start with a simple form, a select box, text box, and submit button. The select box will be used for the search engines, and the text box will be used for the search words.
<center> <form action="web_search.asp" method="post"> <select name="selEngines"> <option value="yahoo">Yahoo</option> <option value="altavista">Alta Vista</option> <option value="excite">Excite</option> <option value="hotbot">Hotbot</option> <option value="lycos">Lycos</option> <option value="msn">MSN</option> <option value="webcrawler">Webcrawler</option> <option value="go">Go</option> </select> <input type="text" name="txtSearchWords" size="30"> <input type="submit" name="btnSearch" value="Search"> </form> </center>
When I listed the search engines' querystrings, notice how I marked the "SEARCHWORDS" in blue.
This is where we want to place the input from our text box
All you need to do is create a simple
If...Then statement with a
Response.Redirect that goes to the
correct search engine, like I've shown below:
If Request.Form("selEngines") = "yahoo" Then Response.Redirect("http://search.yahoo.com/bin/search?p=" & _ Request.Form("txtSearchWords")) End If
Do this for all of the search engines and your all done! (See the code for
In /four_guys/article_four/web_search.asp" target="other">the example I also show you how to achieve the same result with radio buttons. You can even go a step further and do check boxes that will allow you to search multiple engines opening a new window for each one!