views:

28

answers:

1

I have converted a textbox search to Google Search using :

location.href = "http://images.google.com/search?q=" + val;

But, I want options of Web Search, Image Search, Local Search & News Search.

I do have :

<tr height="40">
<td width="80%" align="center" ><input id="searchText" type="text" size="100"/></td>
<td class="searchbox" width="20%" align="center"><a href="#" onclick="startSearch()">Search</a></td>
<td width="0%"></td>
</tr>

<td align="center">
<input type="radio" name="searchType" value="true"/> Web
<input type="radio" name="searchType" value="false"/> Image
<input type="radio" name="searchType" value="false"/> News
<input type="radio" name="searchType" value="false"/> Local
</td>

How do I filter this optiong using the same above link.

+1  A: 

First of all, you really should look into using the Google Search API, which will give you a lot more power and control.

But if you need something quick and dirty, you would want to select the URL before concatenating the query. Here are the urls:

"http://www.google.com/maps?q=" + val;
"http://www.google.com/images?q=" + val;
"http://www.google.com/news?q=" + val;

etc.

So perhaps the thing to do is maintain a global variable that contains the current search URL, and then change that variable in an onclick function for each radio button.

JacobM
Thank you.But the url : "http://images.google.com/news?q=" + val;is incorrect
Sarang