SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    MadCool Webmaster MadCool's Avatar
    Join Date
    Jul 2002
    Location
    NYC
    Posts
    611
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Search Form Manipulation

    I have a search form that points to a search engine, but i would like at add a site search as well. So Is there a way to change the <form method="POST" action="search script here"> based on a pull down menu?:

    If the pull down menu value is "search the web" then the form menthod post should point to 411seek.com/search.cgi

    If the pull down menu value is "search the web" then the form menthod post should point to site.com/directorysearch.cgi

    Above is just an example. I just want to combine two search form into one to save space. Is this possible? Let me know. Thanks!

  2. #2
    SitePoint Evangelist
    Join Date
    Nov 2002
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes you can do that like this:

    Code:
    <form method="post">
    	<select name="slctSearchLocation" onchange="setSearchLocation(this.form)">
    		<option value="http://searchsite1.com">
    		searchsite1.com
    		<option value="http://searchsite2.com">
    		searchsite2.com
    	</select>
    </form>
    <script>
    function setSearchLocation(frm){
        frm.action = frm.slctSearchLocation[frm.slctSearchLocation.selectedIndex].value;
    }
    </script>
    I hope this helps


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
  •