Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: How do you make 1 search box with many choices?

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

    Default How do you make 1 search box with many choices?

    The search form on this forum can search both the vbulletin and google depending on what you click on.

    I want to do this too with my site.

    What script did you use to do this?

  2. #2
    Join Date
    Nov 2006
    Location
    90 miles north of Las Vegas
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Here. Hope you enjoy. Just change the details to what you want.

    <!-- SiteSearch Google -->
    <FORM method=GET action="http://www.google.com/search">
    <input type=hidden name=ie value=UTF-8>
    <input type=hidden name=oe value=UTF-8>
    <TABLE bgcolor="#FFFFFF"><tr><td>
    <A HREF="http://www.google.com/">
    <IMG SRC="http://www.google.com/logos/Logo_40wht.gif"
    border="0" ALT="Google"></A>
    </td>
    <td>
    <INPUT TYPE=text name=q size=31 maxlength=255 value="">
    <INPUT type=submit name=btnG VALUE="Google Search">
    <font size=-1>
    <input type=hidden name=domains value="YOUR DOMAIN NAME"><br><input type=radio name=sitesearch value=""> WWW <input type=radio name=sitesearch value="YOUR DOMAIN NAME" checked> YOUR DOMAIN NAME <br>
    </font>
    </td></tr></TABLE>
    </FORM>
    <!-- SiteSearch Google -->

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

    Default

    No, i dont want google sitesearch. I think you misunderstood me.

    I want ONE search form to be able to have many choices on what you want to search. For example, what this site has. You can choose to search with the vBulletin Search engine or the Google sitesearch engine.

    How do you do this?

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Try this:

    Code:
    <form id="searchForm" action="" method="" onSubmit="sitesearch(this)">
    
    <b>Search:</b><br />
    
    <input id="hiddenquery" type="hidden" name="q">
    <input id="hiddenqueryinternal" type="hidden" name="query">
    <input type="hidden" name="do" value="process">
    <input type="hidden" name="showposts" value="0">
    <input type="hidden" name="quicksearch" value="1">
    <input type="hidden" name="s" value="">
    
    <input name="searchfor" type="text" style="width: 310px;"> <input type="submit" value="Search" /><br>
    
    <div style="font: bold 11px Verdana;"><input name="se" type="radio" checked>Site Search <input name="se" type="radio">Try Google Instead
    </div>
    
    <script type="text/javascript">
    
    function switchaction(curobj, index){
    if (index==0){ //if internal
    document.getElementById("searchForm").action="search.php"
    document.getElementById("searchForm").method="post"
    document.getElementById("hiddenqueryinternal").value=curobj.searchfor.value
    document.getElementById("hiddenquery").value=""
    }
    else if (index==1){ //if Google search
    document.getElementById("searchForm").action="http://www.google.com/search"
    document.getElementById("searchForm").method="get"
    document.getElementById("hiddenquery").value=curobj.searchfor.value
    document.getElementById("hiddenqueryinternal").value=""
    }
    }
    
    function sitesearch(curobj){
    for (var i=0; i< document.getElementById("searchForm").se.length; i++){ //loop through radio to see which is checked
    if (document.getElementById("searchForm").se[i].checked==true)
    switchaction(curobj, i)
    }
    }
    
    
    </script>
    just place that where you want it to appear on your page.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by sartajc View Post
    I want ONE search form to be able to have many choices on what you want to search. For example, what this site has. You can choose to search with the vBulletin Search engine or the Google sitesearch engine.

    How do you do this?
    The best way would be allow the server to decide, sending a redirect to Google if the user chose that option.

    The engine choice would be submitted along with the search terms to the server as normal. If the user chose to use Google, the query would be constructed server-side, and a HTTP redirect would be issued, sending the user to Google. If the built-in search engine was chosen, then the redirect would be skipped and normal processing would resume.

    Exactly how one would go about implementing that depends on what server-side programming language you'd want to use (and would be best addressed in the appropriate forum).

    Mike

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

    Default

    Quote Originally Posted by mwinter View Post
    The best way would be allow the server to decide, sending a redirect to Google if the user chose that option.

    The engine choice would be submitted along with the search terms to the server as normal. If the user chose to use Google, the query would be constructed server-side, and a HTTP redirect would be issued, sending the user to Google. If the built-in search engine was chosen, then the redirect would be skipped and normal processing would resume.

    Exactly how one would go about implementing that depends on what server-side programming language you'd want to use (and would be best addressed in the appropriate forum).

    Mike
    ummm, i want more than just the internal search and google. i wanted to be able to choose search site, arcade, google, blogs, and others.

    see my site: http://muslimonline.org

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

    Default

    Quote Originally Posted by thetestingsite View Post
    Try this:

    Code:
    <form id="searchForm" action="" method="" onSubmit="sitesearch(this)">
    
    <b>Search:</b><br />
    
    <input id="hiddenquery" type="hidden" name="q">
    <input id="hiddenqueryinternal" type="hidden" name="query">
    <input type="hidden" name="do" value="process">
    <input type="hidden" name="showposts" value="0">
    <input type="hidden" name="quicksearch" value="1">
    <input type="hidden" name="s" value="">
    
    <input name="searchfor" type="text" style="width: 310px;"> <input type="submit" value="Search" /><br>
    
    <div style="font: bold 11px Verdana;"><input name="se" type="radio" checked>Site Search <input name="se" type="radio">Try Google Instead
    </div>
    
    <script type="text/javascript">
    
    function switchaction(curobj, index){
    if (index==0){ //if internal
    document.getElementById("searchForm").action="search.php"
    document.getElementById("searchForm").method="post"
    document.getElementById("hiddenqueryinternal").value=curobj.searchfor.value
    document.getElementById("hiddenquery").value=""
    }
    else if (index==1){ //if Google search
    document.getElementById("searchForm").action="http://www.google.com/search"
    document.getElementById("searchForm").method="get"
    document.getElementById("hiddenquery").value=curobj.searchfor.value
    document.getElementById("hiddenqueryinternal").value=""
    }
    }
    
    function sitesearch(curobj){
    for (var i=0; i< document.getElementById("searchForm").se.length; i++){ //loop through radio to see which is checked
    if (document.getElementById("searchForm").se[i].checked==true)
    switchaction(curobj, i)
    }
    }
    
    
    </script>
    just place that where you want it to appear on your page.
    The google one works, but i couldnt get the other ones to work. hmmm, is there any other way? maybe how myspace does it with ajax? (see http://myspace.com)

  8. #8
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by sartajc View Post
    ummm, i want more than just the internal search and google. i wanted to be able to choose search site, arcade, google, blogs, and others.
    So? That just means more radio buttons or select element options, and more if..else statements in the server-side code.

    Mike

  9. #9
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    view http://thetestingsite.net/search.php and see if thats something along the lines of what you need.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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

    Default

    Quote Originally Posted by thetestingsite View Post
    view http://thetestingsite.net/search.php and see if thats something along the lines of what you need.
    WOW, that search is amazing.

    That is REALLY close to what I need. But heres what i need more specifically:

    Search for {box here}
    Where: {Dropdownmenu here}

    The dropdown menu would contain:
    Whole Site
    Forum
    Arcade
    Quran
    Hadith

    This means that when you select something from the dropdown, the javascript or ajax will dynamically change the form action and input name.

    Here is an example of 3 of the forms separately right now:

    HTML Code:
    <tr>
    	<form action="http://muslimonline.org/index.php?act=Search&amp;CODE=01&amp;forums=all" method="post" target="_blank"></form>
    		<td align="right"><input name="keywords" onfocus="this.value=''" value="search..." size="20" type="text"></td>
    		<td align="left"><input class="button" value="Site" type="submit"></td>
    	
    </tr>
    
    <tr>
    	<form action="http://www.muslimonline.org/index.php?act=quran&amp;op=search" method="post" target="_blank"></form>
      		<td align="right"><input name="query" onfocus="this.value=''" value="search..." size="20" type="text"></td>
     		<td align="left"><input class="button" value="Quran" type="submit"></td>
    	
    </tr>
    
    <tr>
    	<form action="http://muslimonline.org/cgi-bin/hadith.cgi" method="post" target="_blank"></form>
    		<td align="right"><input onfocus="this.value=''" name="phrase" value="search..." size="20" type="text"></td>
    		<td align="left"><input class="button" value="Hadith" type="submit"> </td>
    
    	
    <td valign="middle" width="20">
    &nbsp;&nbsp;
    </td>
    </tr>

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
  •