www.webdeveloper.com
Results 1 to 5 of 5

Thread: Frustrated Newby - Search text value based on selections

  1. #1
    Join Date
    Dec 2006
    Posts
    76

    Frustrated Newby - Search text value based on selections

    I am getting desperate. The more I work on this script, the more I think I am messing it up. Could someone PLEASE help me with this? The only things I need are:

    1) I need to have the text box info searched using the selected engine and selected option. (MOST IMPORTANT)
    2) I would like the options to be displayed under the text box (and above the engines).
    3) The options do not display upon page load even though an engine is selected by default. Options for the default should display without having to hit anything.

    I have combined two scripts and included some script that is not being used in case it was needed. I am sure there are errors. Could anyone help? Especially with #1 above.

    Code:
    <html>
    <script>
     
        var google_options = new Array( "Web" , "Images" , "Video" , "News" , "Finance" , "Blogs" , "Catalogs" , "Books" , "Scholar" , "Froogle");
        var google_actions = new Array( "http://www.google.com/search" , "http://images.google.com/images" , "http://video.google.com/videosearch" , "http://news.google.com/news" , "http://finance.google.com/finance" , "http://blogsearch.google.com/blogsearch" , "http://catalogs.google.com/catalogs" , "http://books.google.com/books" , "http://scholar.google.com/scholar" , "http://froogle.google.com/froogle");
        
        var google_variants = new Array(google_options , google_actions);
        
        
        var yahoo_options = new Array( "Web" , "Images" , "Audio" , "Video" , "Shopping" , "Answers" , "Directory" , "My Web");
        var yahoo_actions = new Array( "http://search.yahoo.com/search" , "http://images.search.yahoo.com/search/images" , "http://audio.search.yahoo.com/search/audio" , "http://video.search.yahoo.com/search/video" , "http://shopping.yahoo.com/search" , "http://answers.yahoo.com/search/search_result" , "http://search.yahoo.com/search/dir" , "My Web");
        
        var yahoo_variants = new Array(yahoo_options , yahoo_actions);
        
        
        var metacrawler_options = new Array( "Web" , "Images" , "Audio" , "Video" , "Shopping");
        var metacrawler_actions = new Array( "http://www.metacrawler.com/info.metac/search/web/" , "http://www.metacrawler.com/info.metac/search/images/" , "http://www.metacrawler.com/info.metac/search/audio/" , "http://www.metacrawler.com/info.metac/search/multimedia/" , "http://www.metacrawler.com/info.metac/search/news/");
        
        var metacrawler_variants = new Array(metacrawler_options , metacrawler_actions);
        
        var google = new Array("Google" , google_variants);
        var yahoo = new Array("Yahoo" , yahoo_variants);
        var metacrawler = new Array("Metacrawler" , metacrawler_variants);
        
        var engines = new Array(google , yahoo , metacrawler);// A naming array.
     
        var buttons = new Array();//An array for the three radio buttons of each search engine.
     
     
     
    function DisplayRadio()
    {
    document.getElementById("divdis").innerHTML="";
     
    if(document.getElementById('Google').checked)
      {
      var strmsg='';
      for(var i=0;i<google_options.length;i++)
      {
      strmsg+="<input type='radio' name='options' checked id=Google value='Google'>"+google_options[i];
      }
      document.getElementById("divdis").innerHTML=strmsg;
      }
     
    else if(document.getElementById('Metacrawler').checked)
      {
      var strmsg='';
      for(var i=0;i<metacrawler_options.length;i++)
      {
      strmsg+="<input type='radio' name='options' checked id=Metacrawler value='Metacrawler'>"+metacrawler_options[i];
      }
     
      document.getElementById("divdis").innerHTML=strmsg;
      }
      
    else if(document.getElementById('Yahoo').checked)
      {
      var strmsg='';
      for(var i=0;i<yahoo_options.length;i++)
      {
      strmsg+="<input type='radio' name='options' checked id=Yahoo value='Yahoo'>"+yahoo_options[i];
      }
     
      document.getElementById("divdis").innerHTML=strmsg;
      }
      
    }
    </script>
    <body>
     
    <div style="text-align:center">
      <input name="hl" type="hidden" value="en">
      <input maxlength="2048" name="q" size="55" title="Search string" value="">
      <input type="hidden" name="p">
      <input name="btnG" type="submit" value="Search">
      <input type="reset" name="clear" value="&nbsp;&nbsp;&nbsp;&nbsp;Clear&nbsp;&nbsp;&nbsp;&nbsp;">&nbsp;&nbsp;&nbsp;&nbsp;
      </div>
     
    <br>
    <div style="text-align:center">
      <input type="radio" name="engine" checked id=Google value="Google"
       onClick="DisplayRadio();"><A HREF="http://www.google.com" target="_blank"><font face="arial" size="2"><b>Google</b></font></A><br>
      <input type="radio" name="engine" id=Metacrawler value="Metacrawler"
       onClick="DisplayRadio();"><A HREF="http://www.metacrawler.com" target="_blank"><font face="arial" size="2"><b>Metacrawler</b></font></A><br>
      <input type="radio" name="engine" id=Yahoo value="Yahoo"
       onClick="DisplayRadio();"><A HREF="http://www.yahoo.com" target="_blank"><font face="arial" size="2"><b>Yahoo</b></font></A><br>
    <div id=divdis ></div>
    </body>
    </html>

  2. #2
    Join Date
    Dec 2006
    Posts
    76

    I Would Appreciate Some Help

    The only thing I need at this point is to have the text box info searched using the selected engine and selected option.

    PLEASE, someone help.

  3. #3
    Join Date
    Mar 2007
    Posts
    5
    hai scrabble,
    i am not able to get your problem.
    please specify the problem and tell me what do u need actually.
    for your 3rd point please make some alteration in your code.
    put this code instead of ,<body> in your code.
    this is what i understood by ur post.

    <body onload ="DisplayRadio();">

    and let me know soon.

    with regards,
    Purushotham.DK
    Mysore,Karnataka,
    India.

  4. #4
    Join Date
    Dec 2006
    Posts
    76
    I only need one thing:

    Ex. If 'Google' is chosen, and if 'Images' is chosen, and if in the textbox was typed 'Bill Cosby'

    ...then...

    the script would check google_actions since the 'Google' engine and the 'Images' option was chosen...and it would result in opening the page with results from Google's images of Bill Cosby.


    Same goes if Yahoo or Metacrawler (or any others I may end up adding) was checked and corresponding option to each.
    Last edited by Scrabble; 03-22-2007 at 09:29 PM.

  5. #5
    Join Date
    Mar 2007
    Posts
    5
    hai scrabble,
    Have look over this code and let me know is that correct..
    with regards,
    Purushotham.DK
    Mysore.karnataka,India.

    <html>
    <script>

    var google_options = new Array( "Web" , "Images" , "Video" , "News" , "Finance" , "Blogs" , "Catalogs" , "Books" , "Scholar" , "Froogle");
    var google_actions = new Array( "http://www.google.com/search" , "http://images.google.com/images" , "http://video.google.com/videosearch" , "http://news.google.com/news" , "http://finance.google.com/finance" , "http://blogsearch.google.com/blogsearch" , "http://catalogs.google.com/catalogs" , "http://books.google.com/books" , "http://scholar.google.com/scholar" , "http://froogle.google.com/froogle");

    var google_variants = new Array(google_options , google_actions);


    var yahoo_options = new Array( "Web" , "Images" , "Audio" , "Video" , "Shopping" , "Answers" , "Directory" , "My Web");
    var yahoo_actions = new Array( "http://search.yahoo.com/search" , "http://images.search.yahoo.com/search/images" , "http://audio.search.yahoo.com/search/audio" , "http://video.search.yahoo.com/search/video" , "http://shopping.yahoo.com/search" , "http://answers.yahoo.com/search/search_result" , "http://search.yahoo.com/search/dir" , "My Web");

    var yahoo_variants = new Array(yahoo_options , yahoo_actions);


    var metacrawler_options = new Array( "Web" , "Images" , "Audio" , "Video" , "Shopping");
    var metacrawler_actions = new Array( "http://www.metacrawler.com/info.metac/search/web/" , "http://www.metacrawler.com/info.metac/search/images/" , "http://www.metacrawler.com/info.metac/search/audio/" , "http://www.metacrawler.com/info.metac/search/multimedia/" , "http://www.metacrawler.com/info.metac/search/news/");

    var metacrawler_variants = new Array(metacrawler_options , metacrawler_actions);

    var google = new Array("Google" , google_variants);
    var yahoo = new Array("Yahoo" , yahoo_variants);
    var metacrawler = new Array("Metacrawler" , metacrawler_variants);

    var engines = new Array(google , yahoo , metacrawler);// A naming array.

    var buttons = new Array();//An array for the three radio buttons of each search engine.



    function DisplayRadio()
    {
    document.getElementById("divdis").innerHTML="";

    if(document.getElementById('Google').checked)
    {
    var strmsg='';
    for(var i=0;i<google_options.length;i++)
    {
    strmsg+="<input type='radio' name='options' checked id=Google value='Google'>"+google_options[i];
    }
    document.getElementById("divdis").innerHTML=strmsg;
    }

    else if(document.getElementById('Metacrawler').checked)
    {
    var strmsg='';
    for(var i=0;i<metacrawler_options.length;i++)
    {
    strmsg+="<input type='radio' name='options' checked id=Metacrawler value='Metacrawler'>"+metacrawler_options[i];
    }

    document.getElementById("divdis").innerHTML=strmsg;
    }

    else if(document.getElementById('Yahoo').checked)
    {
    var strmsg='';
    for(var i=0;i<yahoo_options.length;i++)
    {
    strmsg+="<input type='radio' name='options' checked id=Yahoo value='Yahoo'>"+yahoo_options[i];
    }

    document.getElementById("divdis").innerHTML=strmsg;
    }

    }
    function Se()
    {
    /*Here if you send spaced values in textbox then you need to concat those by using + */
    if(document.getElementById('Google').checked)
    {
    var strmsg=document.getElementById("q").value+'&meta=';
    window.open("http://www.google.co.in/search?hl=en&q="+strmsg,'','','');
    }
    else if(document.getElementById('Metacrawler').checked)
    {
    var strmsg='';

    }

    else if(document.getElementById('Yahoo').checked)
    {
    var strmsg='';

    }

    }
    </script>
    <body onload="DisplayRadio();">

    <form >
    <div style="text-align:center">
    <input name="hl" type="hidden" value="en">
    <input maxlength="2048" name="q" size="55" id=q title="Search string" value="sasas">
    <input type="hidden" name="p">
    <input name="btnG" type="submit" value="Search" onclick="Se();">
    <input type="reset" name="clear" value="&nbsp;&nbsp;&nbsp;&nbsp;Clear&nbsp;&nbsp;&nbsp;&nbsp;">&nbsp;&nbsp;&nbsp;&nbsp;
    </div>

    <br>
    <div style="text-align:center">
    <input type="radio" name="engine" checked id=Google value="Google"
    onClick="DisplayRadio();"><A HREF="http://www.google.com" target="_blank"><font face="arial" size="2"><b>Google</b></font></A><br>
    <input type="radio" name="engine" id=Metacrawler value="Metacrawler"
    onClick="DisplayRadio();"><A HREF="http://www.metacrawler.com" target="_blank"><font face="arial" size="2"><b>Metacrawler</b></font></A><br>
    <input type="radio" name="engine" id=Yahoo value="Yahoo"
    onClick="DisplayRadio();"><A HREF="http://www.yahoo.com" target="_blank"><font face="arial" size="2"><b>Yahoo</b></font></A><br>
    <div id=divdis ></div>
    </form>
    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles