How can I set up hyperlinks to be filled in from an input box?

I have a small HTML page on my desktop with links to several useful pages - http://www.google.com, http://www.dictionary.com, http://www.straightdope.com etc.

Some of the sites are search based (dictionary.com for example) and I have to visit the homepage, enter the search and then go to the result page.

The typical URL is http://www.dictionary.com/cgi-bin/dict.pl?term=Monkey, where Monkey is the search term.

Is there anyway to setup a link from my local page that prompts me for a search term and takes me directly to http://www.dictionary.com/cgi-bin/dict.pl?term=searchterm?

Sure, I do this all the time. Instead of a hyperlink, you need to embed an HTML form in your page. Using your dictionary example, to call up the page for http://www.dictionary.com/cgi-bin/dict.pl?term=searchterm, you add the following to your page:
[ul]<form action=“http://www.dictionary.com/cgi-bin/dict.pl”>
Search dictionary.com: <input type=“text” name=“term”>
<input type=“submit” value=“Search”>
</form>[/ul]
This should display a text field and a “Search” button. Type searchterm in the text field, click on the button.

If the target page requires more than one parameter, e.g. http://www.dictionary.com/cgi-bin/dict.pl?lang=italian&term=searchterm, you can add more text fields for those, or if their values never change you can add “hidden” fields:
[ul]<form action=“http://www.dictionary.com/cgi-bin/dict.pl”>
<input type=“hidden” name=“lang” value=“italian”>
Search dictionary.com: <input type=“text” name=“term”>
<input type=“submit” value=“Search”>
</form>[/ul]
There are other options you can add to the <input> tag. Check out http://www.htmlhelp.com/reference/wilbur/ for more information.

Damnit!
I was beaten here!
Oh, well… all this hard work, I’m gonna post somthing:
<TABLE cellpadding=“5”>
<TR bgcolor="#ABCDEF">
<form method=“get” action=“http://www.dictionary.com/cgi-bin/dict.pl”>
<td>
<input type=“text” name=“term” size=“15”><br>
<input type=“submit” value=“Search”>
<input type=“reset” value=“PANIC!”> <!-- Clears the textbox --!>
</td>
</form>
</table>

With added extras! :slight_smile:
See also:
http://www.w3.org/TR/REC-html40/

http://www.dictionary.com/cgi-bin/dict.pl?term=thanks :smiley:

Just a note - I would suggest that you explicitly use the method=“get” attribute as in wolfseyn’s example. That’s the way forms are supposed to default, but it is good practice to always state the method on form tags. People tend to forget the way it defaults, and it can lead to a lot of confusion. To do what you want, “get” is the method you need, and you can just slap it on and stop reading if you like - since I brought it up, I’ll explain the distinction.

Forms can be either method=post or method=get. The difference is in how data is transferred from the fields in the form. For “get”, the fields are attached to the URL, making it identical to having typed the URL with the “?” and “&” stuff, which is why “get” is appropriate for the purpose being discussed. For “post”, the fields are transmitted as the body of the message, and the URL given in the action is unmodified. If you have very much data, “post” is needed to avoid huge URL’s, but “get” leads to a bookmarkable target pages.

(You now know what the browser is talking about when it gives you that silly message about “page resulted from a POST operation”.)

These days, many server side applications are written so as to accept either method without distinguishing where their parameter input came from, but not always.