PDA

View Full Version : One search form with multiple options



sartajc
12-07-2006, 07:53 AM
Ive asked this question before but didn't get an answer, so here im asking again.

How can you have one search form have the option of search multiple things? aka forum, arcade, site, google, etc.

It would be like this:

Seach the (dropdown menu with search options) for (search query) (submit button)

Basically, the javascript would need to be able to dynamically change the form action, method and input name.

I know sites like the new yahoo.com do this, and so does myspace.com . this sites forum kinda does it too with the "use google instead' option. but how can i do that with a dropdown menu instead?

ddadmin
12-07-2006, 12:30 PM
The closest script I'm aware of would be this one: http://www.javascriptkit.com/script/script2/multi_site_search.shtml It doesn't use a drop down, though that can be changed easily. The real stumbling block is that you wanted it to use additional sites besides the major search engines for the search. That would require knowing how the queries in each search case is transmitted, which isn't as straightfoward as plug and play.

sartajc
12-08-2006, 08:13 AM
How does this site do it? with the choice of internal search and google?

ddadmin
12-08-2006, 10:11 AM
Basically the same way the linked script does for various search engines- by finding out the URL GET string used by the search service in question to create the search, plus any hidden form field values that may be passed as well. You're welcome to view source to try and recreate this script on your site, though unfortunately I don't have the time to package it as a downloadable script.

sartajc
12-08-2006, 07:20 PM
I actually figured out how it can work.
See it at www.muslimonline.org (the search form in the banner)

You think I can submit this to Dynamic Drive or something?

Its really simple. And it allows you to change the input name, form action, and form method.


<script type="text/javascript">
function updateSearch(params,frm) {
var data = params.split(">>>");
frm.method = data[0];
frm.action = data[1];
document.getElementById("searchBox").name = data[2];
}
</script>

<form method="post" action="searchsite.php">
<input type="text" id="searchBox" name="searchSite" value="search for..." onfocus="this.value=''" size="15" />


<select onchange="updateSearch(this.value,this.form);">
<option

value="post>>>http://muslimonline.org/index.php?act=Search&amp;CODE=01&amp;forums=all>>>keywords">in Forum</option

>
<option value="post>>>http://muslimonline.org/arcade.html>>>gsearch">in Arcade</option>
<option

value="post>>>http://www.muslimonline.org/index.php?act=quran&amp;op=search>>>query">in Quran</option>
<option value="post>>>http://muslimonline.org/cgi-bin/hadith.cgi>>>in phrase">Hadith</option>


</select>

</form>