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!

Hello Guys, Need help with search from my site to other sites 2

Status
Not open for further replies.

Melissahomes

Programmer
May 13, 2005
8
US
Basically,

I want a form where a user can choose (from a combobox)which site they want to search (google.com, etc..) and it takes them to that site with the search results.

What would be the best way to do this??

Melissa.
 
You can have a drop down box where they can choose the site they want to go to, but how are they determining what the search criteria are supposed to be? You will need to be a little more clear in what you are seeking to do.

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
Well they would enter the search in a text box next to the combobox. I know how to do this in theory but not with ASP.
 
so you want to send the text entered by the user on your website as a query string to the site they select from the dropdown list??

-DNG
 
Well, you will need to make certain that you know how the search functionality works for each of the potential pages that you send the user to. I believe for Google it uses the query string, but others may be different. You would have to account for that when you do your redirect.

You would have to create your dropdown box with the items listed in it and then a textbox that would allow for the user to enter their criteria. Finally, you would probably want a submit button that, when clicked, will redirect the user to the new site with a properly formatted query string (using server.URLEncode).

Honestly, I would probably just allow them to go to the main page of the new site and allow them to enter their own criteria there because there may be different ways to search - literal phrase, several words, one word, etc...

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
I think you need to use a XMLHTTP object. Below a little sample code to get you started.

Code:
    set xml = Server.CreateObject("Microsoft.XMLHTTP")

  ' Version 3.0 of XMLHTTP, use:
  ' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

  ' Opens the connection to the remote server.
    xml.Open "GET", "[URL unfurl="true"]http://www.google.com/search?q=your[/URL] search string here", False


    xml.Send

    Response.Write (xml.responseText)
    xml = Nothing

-DNG
 
How do I use the code above with my form? Here is the code for my form thus far...

<form name="form1" method="post" action="">
<input name="search" type="text" id="search">
<select name="site" id="site">
<option value=" </select>
<input name="Search" type="reset" id="Search" value="Search">
</form>
 
sorry, but our intranet users want it so they can enter in the search terms from our page.

 
I would have the page post back to itself and at the top of your page some ASP code that will check to see whether the user clicked on the Search button. If so, then redirect them to the option value that was chosen in the form with the search criteria appended to the end. You will also need to change the names of some of the controls in your example (you should not have two items both named "search").

Something akin to the following (this is just a rough sample, you will need to further modify for it to work for your page):
Code:
<% [COLOR=green]'put this at top of the page[/color]
if len(request.form("Search")) then 
  dim newRoute
  newRoute = request.form("site")
  newRoute = newRoute & server.URLEncode(request.form("searchCriteria")) [COLOR=green]'You will definitely need to play around with the syntax here to get it to do what you want it to do.  Also bear in mind that this will only work provided that the page you're going to uses this form of syntax.  This is why I suggested letting the users go to the main page else you will have to do much more work here.[/color]
  response.redirect(newRoute)
end if
%>

<form name="form1" method="post" action="">
  <input name="searchCriteria" type="text" id="searchCriteria">
  <select name="site" id="site">
    <option value="[URL unfurl="true"]http://www.google.com/search?q=">Google</option>[/URL]
  </select>
  <input name="Search" type="reset" id="Search" value="Search">
</form>

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
try something like this:
Code:
YourFormPage.asp
<form name="form1" method="post" action="YourActionPage.asp">
  <input name="search" type="text" id="search">
  <select name="site" id="site">
    <option value="google">Google</option>
  </select>
  <input name="Search" type="reset" id="Search" value="Search">
</form>
YourActionPage.asp
Code:
searchTerm=Request.Form("search")
websiteSelected=Request.Form("google")

Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
    xml.Open "GET", "[URL unfurl="true"]http://www.google.com/search?q=&searchTerm",[/URL] False


    xml.Send

    Response.Write (xml.responseText)
    xml = Nothing

-DNG
 
I would go with chopstik's suggestion. The sample codes we both presented needs lot of tweaking to function correctly and it also depends on the websites to which you are redirecting...

-DNG
 
Melissahomes said:
sorry, but our intranet users want it so they can enter in the search terms from our page.

I fear that you have been mislead.

Your intranet users would just as well go to yahoo or google. They could care less.

Really.

In fact, they might actually rather go directly to one of the other sites because they are that much closer to logging into their "web email" that they use to trade dirty jokes and pictures since its been banned on the corporate email.

You want the truth?

The truth is that this is nothing but a desparate ploy to get users to actually use the company's IntrAnet web site.

Somebody is in hot water because they spent a lot of money on an internal website that nobody uses. The hope is that at least SOME of them will use this instead of going straight to google.

This search page won't help in the long run. People will only look at web sites that have good useful content. Your intranet apparantly does not.

Sorry to be the one that brings bad news.

:-(

PS: Don't feel bad. Most companies have the same problem.
 
Are you kidding me.

"Your intranet users would just as well go to yahoo or google. They could care less."

They do care. Because when I removed the search form from our intranet that allowed users to search for medical terms, google, internal search engine, webster's dictionary.. they all complained. I was just going to allow internal search and thats it.

And nobody is in hot water, our intranet was developed in house and did not cost much money.

It's quite amusing how presumptious people can be. ie judging a restaurant based on one dish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top