?
Solved

Radio button multisearch form

Posted on 1997-04-04
1
Medium Priority
?
327 Views
Last Modified: 2008-03-03
I was hoping that you could help me with a little javascript problem
that I have.
While surfing around the net I have come upon some multiple search
forms. They use one input field to access numerous search engines. The
most basic of these that I have seen is the one that I am trying to work
with.
Its code follows...

<head>
     <script language="JavaScript">
        var FirstForm;
           function StartSearch(){
             
document.forms[FirstForm+document.InputForm.SearchSelect.selectedIndex].elements[0].value=document.InputForm.SearchWords.value;
             
document.forms[FirstForm+document.InputForm.SearchSelect.selectedIndex].submit();
           }
     </script>
  </head>
  <body>
     <form Name="InputForm">
        Search For: <input name="SearchWords" type=text size=30>
        Search Engine: <select Name="SearchSelect">
           <option selected>Yahoo
           <option>Altavista
           <option>Excite
           <option>Lycos
        </select>
        <input type=button value="Search" onClick="StartSearch()">
     </form>

     <script
language="JavaScript">FirstForm=document.forms.length</script>

     <form action="http://search.yahoo.com/bin/search" method=get>
        <input type="hidden" size=35 name=p>
     </form>

     <form action="http://www.altavista.digital.com/cgi-bin/query"
method=get>
        <input type="hidden" name=q size=35 maxlength=200 value="">
        <input type="hidden" name=pg value=q>
        <input type="hidden" name="fmt" value=".">
        <input type="hidden" name=what value=web>
     </form>

     <form action="http://www.excite.com/search.gw" method=post>
        <input type="hidden" name="search" size=35>
        <input type="hidden" name="searchType" value="Keyword">
        <input type="hidden" name="category" value="default" checked>
        <input type="hidden" name="mode" value="relevance">
        <input type="hidden" name="showqbe" value="1">
        <input type="hidden" name="display" value="html3,hb">
     </form>

     <form
action="http://www.lycos.com/cgi-bin/nph-randurl/cgi-bin/largehostpursuit1.html">
        <input type=hidden size=35 name="query">
     </form>
  </body>

The above, as you see, only uses very limited javascript to get the job
done. For me this is fine and while this is okay I would like to be able
to use radio buttons to make the selection instead of the option box.
I am sure that this is possible but for me it has not been something I
have been able to do. Believe me, I have tried, but my limited
javascript knowledge is my downfall here.

The following is one of my atempts...

<HTML>
<head>
<SCRIPT language="JavaScript">
        var FirstForm;

        function StartSearch(form){
        for (Count = 0; Count < 4; Count++) {
                if (form.SearchSelect[Count].checked)
                        break;
                {
       
document.forms[FirstForm+document.form.SearchSelect.checked].elements[0].value=document.InputForm.SearchWords.value;
               
document.forms[FirstForm+document.form.SearchSelect.checked].submit();
                }
        }
}
</script>
</head>

<body>

<form Name="InputForm">
Search For: <input name="SearchWords" type=text size=30>
<input type=button value="Search" onClick="StartSearch(form)">
<br>
<br><br>
Search Engine:
<BR>
<INPUT TYPE="radio" NAME="SearchSelect" CHECKED onClick=0>Yahoo<BR>
<INPUT TYPE="radio" NAME="SearchSelect" onClick=0>Altavista<BR>
<INPUT TYPE="radio" NAME="SearchSelect" onClick=0>Excite<BR>
<INPUT TYPE="radio" NAME="SearchSelect" onClick=0>Lycos<BR>

</FORM>

<br></form>

    <script
language="JavaScript">FirstForm=document.forms.length</script>

    <form action="http://search.yahoo.com/bin/search" method=get>
       <input type="hidden" size=35 name=p>
    </form>

    <form action="http://www.altavista.digital.com/cgi-bin/query"
method=get>
       <input type="hidden" name=q size=35 maxlength=200 value="">
       <input type="hidden" name=pg value=q>
       <input type="hidden" name="fmt" value=".">
       <input type="hidden" name=what value=web>
    </form>

    <form action="http://www.excite.com/search.gw" method=post>
       <input type="hidden" name="search" size=35>
       <input type="hidden" name="searchType" value="Keyword">
       <input type="hidden" name="category" value="default" checked>
       <input type="hidden" name="mode" value="relevance">
       <input type="hidden" name="showqbe" value="1">
       <input type="hidden" name="display" value="html3,hb">
    </form>

    <form
action="http://www.lycos.com/cgi-bin/nph-randurl/cgi-bin/largehostpursuit1.html">
       <input type=hidden size=35 name="query">
    </form>

</BODY>

I don't know, was I on the right track with this?
I am sure that you see what I am trying to do here. Can you help me with
this? As I said, my javascript knowledge is very limited at this time,
so be as simplistic as possible in your solutions to my problem please!
If a "solution" to my problem can be given it would be greatly
appreciated.

Regards,

Owen.
0
Comment
Question by:owen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
moorep earned 100 total points
ID: 1265134
why not include the url as the value of the option (give the option buttons all the same names) and then concatenate the query  to this value (with appropriate parameters) in a JavaScript function. Use a <INPUT TYPE="button" onClick="MyFunc()">
instead of a submit button.
<SCRIPT etc>
function MyFunc() {
    document.location=SearchSelect.value+"bin/query?p="+MyQuery.value;
// end func
}
</SCRIPT>
<FORM etc>
<INPUT TYPE=text NAME="MyQuery">
<INPUT TYPE="radio" NAME="SearchSelect" VALUE="http://www.yahoo.com/">YAHOO
<INPUT TYPE="radio" etc.....
<INPUT TYPE=button VALUE="Search" onClick="MyFunc()">
</FORM>
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question