Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I make a drop-down box to relate to a text box?

Status
Not open for further replies.

mark01

Technical User
Jan 17, 2001
600
US
How would I go about making a drop down box with search engines listed in them, then have a text box after that drop-down box that you will be able to type in a search string, then have it goto the appropriate internet search engine site that you listed in the drop-down box??
 
<script>

function findIt()
{
var criteria,engine,search,frm;
frm = document.benlucbenluc
criteria = frm.benlucben.value;
engine = frm.benluc.options[frm.benluc.selectedIndex].value;
switch(engine)
{
case '1':
search=&quot; break;
case '2':
search=&quot; break;
case '3':
search=&quot; }
window.location=search
}
</script>

<form action=&quot;javascript:findIt()&quot; name=&quot;benlucbenluc&quot;>
Search for:&nbsp;<input name=&quot;benlucben&quot;>&nbsp;with
<select name=&quot;benluc&quot;>
<option value=&quot;1&quot;>Altavista
<option value=&quot;2&quot;>Yahoo
<option value=&quot;3&quot;>Web Crawler
</select>
<script>
if(document.all){document.write('<input type=&quot;submit&quot; value=&quot;Search&quot;>')}
else{document.write('<input type=&quot;button&quot; onClick=&quot;findIt()&quot; value=&quot;Search&quot;>')}
</script>

</form>
jared@eae.net -
 
One more question... It works good, but when I type in a &quot;+&quot; before the word I am searching for, it doesn't put the + in on the search engine. It puts everything else in (-,&quot;&quot;) but not the + sign. Example - Search for +utah +jazz, will bring up utah jazz. It just puts in a space instead of a plus. But if I search for &quot;utah jazz&quot;, it will bring up &quot;utah jazz&quot;. How can I fix this so that the + sign will work in the search???
 
You'll need to use the encode function to convert the plus signs to %xx format. In a normal url, a plus sign means a space. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Sorry, I meant the escape function, and I notice that the code jaredn posted for you already uses the escape function on the criteria before attaching it to the url, so it should have taken care of the plus signs, unless there is a bug in the escape function. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Does anyone know how to fix the escape function???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top