Results 1 to 5 of 5
  1. #1

    Multiple Search Options - Radio Buttons Instead Of Drop Down List

    The tutorial on how to make a search form with multiple search options was excellent!

    http://www.mediacollege.com/internet...ti-search.html

    However, is it possible to use radio buttons instead of a drop-down list? Can someone be kind enough to show me the code for it?

    Million thanks.

  2. #2
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    Try this:

    Code:
    <form name="searchform" onSubmit="return dosearch();">
    Search:<br />
    <input name="sengines" type="radio" value="http://www.google.com/search?q="> Google<br />
    <input name="sengines" type="radio" value="http://www.altavista.com/web/results?q="> Alta Vista<br />
    <input name="sengines" type="radio" value="http://www.dogpile.com/info.dogpl/search/web/"> Dogpile<br />
    <input name="sengines" type="radio" value="http://search.yahoo.com/search?p="> Yahoo!<br /> 
    For: 
    <input type="text" name="searchterms">
    <input type="submit" name="SearchSubmit" value="Search">
    </form>
    Dave Owen
    MediaCollege.com

  3. #3
    The drop down search form works in Firefox and IE7, but not with the radio buttons code that's been posted. I'd really appreciate any help on this.

  4. #4
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    Sorry, I should have tested it first. I forgot that you will also need to change the function in the head. Replace the head code with this:

    Code:
    <script language="JavaScript">
    function dosearch() {
     var sf=document.searchform;
      for (i=sf.sengines.length-1; i > -1; i--) {
       if (sf.sengines[i].checked) {
        var submitto = sf.sengines[i].value + escape(sf.searchterms.value);
       }
      }
      window.location.href = submitto;
      return false;
    }
    </script>
    I've put all the necessary code together here:
    http://www.mediacollege.com/internet...rch-radio.html
    Dave Owen
    MediaCollege.com

  5. #5
    Thanks very much Dave, that's great.

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
  •  
Subscribe to us on YouTube