Advanced Search

Results 1 to 5 of 5

Thread: One search form with multiple options

  1. #1
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default One search form with multiple options

    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?

  2. #2
    Join Date
    Aug 2004
    Posts
    9,864
    Thanks
    3
    Thanked 960 Times in 949 Posts
    Blog Entries
    15

    Default

    The closest script I'm aware of would be this one: http://www.javascriptkit.com/script/...e_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.

  3. #3
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    How does this site do it? with the choice of internal search and google?

  4. #4
    Join Date
    Aug 2004
    Posts
    9,864
    Thanks
    3
    Thanked 960 Times in 949 Posts
    Blog Entries
    15

    Default

    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.

  5. #5
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

    HTML Code:
    <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>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •