Results 1 to 9 of 9

Thread: Search form to search Yahoo and My website at the same time

  1. #1
    Join Date
    Jun 2015
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Search form to search Yahoo and My website at the same time

    Hello, I have this code from http://www.javascriptkit.com/script/...e_search.shtml which I could easily modify it to search Yahoo and My Website. But the code searches for example, yahoo or Google one after the orther using radio button and then open the results in a new tab (new window). I would need some help to modify the code so that, it searches Yahoo and My website AT THE SAME TIME and then display the results in the same page side by side (Yahoo results will be on one side and My Web sites result would be on one side. e.g right). Here is the code I found:

    Code:
    <form name="jksearch" action="http://www.google.com/search" method="get" onSubmit="jksitesearch(this)">
    
    <p>Search JavaScript Kit:<br />
    <input id="hiddenquery" type="hidden" name="q" />
    <input name="qfront" type="text" style="width: 200px" value="navigator object" /> <input type="submit" value="Search" /><br />
    <div style="font: bold 11px Verdana;">Google:<input name="se" type="radio" checked>  Yahoo:<input name="se" type="radio">  MSN:<input name="se" type="radio">
    </div>
    
    <script type="text/javascript">
    
    // All-in-one Internal Site Search script- By JavaScriptKit.com (http://www.javascriptkit.com)
    // For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
    // This notice must stay intact for use
    
    //Enter domain of site to search.
    var domainroot="www.javascriptkit.com"
    
    var searchaction=[ //form action for the 3 search engines
    "http://www.google.com/search",
    "http://search.yahoo.com/search",
    "http://search.msn.com/results.aspx"
    ]
    
    var queryfieldname=["q","p","q"] //name of hidden query form for the 3 search engines
    
    function switchaction(cur, index){
    cur.form.action=searchaction[index]
    document.getElementById("hiddenquery").name=queryfieldname[index]
    }
    
    function jksitesearch(curobj){
    for (i=0; i< document.jksearch.se.length; i++){ //loop through radio to see which is checked
    if (document.jksearch.se[i].checked==true)
    switchaction(document.jksearch.se[i], i)
    }
    document.getElementById("hiddenquery").value="site:"+domainroot+" "+curobj.qfront.value
    }
    
    
    </script>
    
    </p>
    
    </form>
    
    <p style="font: normal 11px Arial">This free script provided by<br />
    <a href="http://www.javascriptkit.com">JavaScript Kit</a></p>
    anything Like in the attached image or better would be great for me. I would greatly appreciate any help. Thank you!

    Click image for larger version. 

Name:	searchform.jpg 
Views:	212 
Size:	47.4 KB 
ID:	5690

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,035
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    What you want isn't possible with this particular script. It's a very simple script that is only passing a query string to the 3rd party search provider's website, where the results are returned in the external website page. You can perform the same type of search manually by browsing to the search engine home page and doing a "site:[domain] [keywords]" search for any website.

    The script could possibly be edited to return the page from Yahoo/Google/MSN inside an iframe on your site - if it abides by the service provider's usage terms, but I believe that in the case of Google, that isn't permitted because they don't allow framing (see point 1.3 https://support.google.com/customsearch/answer/1714300) - but you wouldn't be able to style it (it's somebody else's website).

    However, you can create and customise a Google search box and its results using their CSE https://cse.google.com/cse/

    Note that I haven't explored the other search providers search APIs (if they even have them) so you should research those and read their terms of service yourself to see what you can and can't manipulate.

    If you want full control over your internal search engine, that can be styled to look like an integral part of your website, without ads and in your preferred layout, you would need to use a more advanced, server-side script that you host on your own website and run from a database. This script would index all the pages of your site, store text in the database and then return results from that database in your own stylable page. So maybe try one of these http://www.javascriptkit.com/howto/search2.shtml
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Jun 2015
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you Beverleyh for the informative reply. And yes, I would prefer the iframe option, Yahoo allows the Iframe and my website allows the iframe. I am looking for a way to have the script display the search results in two iframes on the same page of my website. The reason is that, I want the searh results from my website to be related to the search results from Yahoo. Hence when a user enters a keyword for example and clicks on search (once), the script should pass query string to Yahoo and to my website at the same time and display the search results in iframes. (one iframe for yahoo results, another for my website's results) I am not worried about customizing the search results as I am ok to leave the look of the results as is. I hope I have been clear to receive your help regarding modifying the script above to perform the fuction described. Thanks once again.

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,035
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I want the searh results from my website to be related to the search results from Yahoo.
    So just to be clear, what exactly are you wanting to happen?

    1) Use the JavaScriptKit search script to perform 2 searches via Yahoo that A, returns a general "keyword" search of the whole web, and B, returns a "site: yourdomain.com keyword" search of your site only. You'd be using Yahoo in both cases to compare search terms found globally with those found in your site.

    OR

    2) Use the JavaScriptKit search script to perform 1 search via Yahoo that returns a "site: yourdomain.com keyword" search of your site only, and additionally use an internal self-hosted database search engine to return "keyword" results from your site only. You'd be comparing how Yahoo finds keywords in your site to how the self-hosted script finds keywords in your site.

    If you're wanting option 2, you need to research and install a self-hosted search script and the form would need to have both search scripts integrated. and in order to help with integration, we'd need a link to the page on your site with your internal search engine installed (and possibly a copy of the server-side processing script that submits the search query).

    But if you're wanting option 1, somebody could probably help you with modifying the JavaScriptKit code to run 2 search functions into 2 separate iframes in the results page.

    Just one problem though - affecting both options; When a link is clicked, the framed results would open inside their respective iframes. With the returned pages being part of the Yahoo website, I don't see a way around making a click on one of their linked search results open up in the parent frame (see same origin policy https://developer.mozilla.org/en-US/...-origin_policy ). And that wouldn't be a very good user experience.

    I personally think you'd be better off using a self-hosted script, returning results from your site only. I don't know anything about your project so I'm just commenting from experience, but I can't see how a side-by-side comparison could be beneficial to the end user (unless it was an internal analysis tool for a more technically aware user, who wouldn't judge the choppy look of 2 iframes, and who would be aware of opening results inside the iframes).
    Last edited by Beverleyh; 06-14-2015 at 03:21 PM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    Jun 2015
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you Beverleyh,
    OPTION TWO: This site I will be designing will be be a Joomla site using Joomla's internal default search engine so the database and the stuff are already there just as Yahoo's search engine is already there.

    Assuming BUS is the keyword to be searched for and my website is hosted at www.example.com, then this url http://example.com/index.php/compone...searchword=BUS would present a page displaying results from my website for the keyword BUS, retrieved from the site's database

    AT YAHOO
    Also this Yahoo url http://search.yahoo.com/search?p=BUS will present Yahoo search results for the keyword BUS on Yahoo's page

    WHAT I WANT
    I want a javascript that will create iframe for results retrieved by http://search.yahoo.com/search?p=Boy and another for results retrieved by http://example.com/index.php/compone...searchword=BUS so that both iframes with their results are side by side on my website when the keyword BUS is being searched for in the search box provided by the Javascript.

  6. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,035
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I don't think you need the JavaScriptKit code or its form then. What I think you need is a custom script (possibly using aspects of the JavaScriptKit one) that is integrated into the default Joomla search processing script/template/page. I expect that the internal script is PHP based, which means that it runs on the server-side before page generation, so the JavaScript that performs the Yahoo search would probably be integrated into the results page and run afterwards, on page load, creating a short delay while the results return and populate the IFrame.

    But without a link to the search page and the results page, or a copy of the processing scripts, it's almost impossible to help.

    Moving forward, I think you have 3 possible choices;

    1) You can post this as a custom job in the paid help request forum with a view to working with a developer who you give server access to http://www.dynamicdrive.com/forums/f...-Work-Requests

    2) Leave the request here and hope that somebody who knows the default Joomla search scripts writes the custom code for you.

    3) Post in the Joomla forum and ask somebody there with Joomla experience to write your custom code for you http://forum.joomla.org/
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  7. #7
    Join Date
    Jun 2015
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    (1) The javaScript above already does something very close to what I want. It passes the query string to open the search results in a new window
    (2)The JavaScript uses "radio", e.g <input name="se" type="radio"> so that only one search engine can be selected at a time

    All I want is

    (1) for the javascript to pass the query string to open the search results in iframe (not in new window)
    (2) to use checkbox instead of radio so that two search engines can be selected at a time

    Knowlege of Joomla is not required at all in this

  8. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,035
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Quote Originally Posted by Elizabet View Post
    Knowlege of Joomla is not required at all in this
    Quote Originally Posted by Elizabet View Post
    OPTION TWO: This site I will be designing will be be a Joomla site using Joomla's internal default search engine so the database and the stuff are already there just as Yahoo's search engine is already there.
    ---

    Quote Originally Posted by Elizabet View Post
    The javaScript above already does something very close to what I want.
    On face-value it does *seem* to do that. But a looking deeper into your requirements (as I've understood them from your comments in this thread) and knowing what is possible with the technology used, any experienced developer will tell you that JavaScript is not the right tool for the job (and let's assume that you're asking for help in a coding forum because you haven't yet got the experience to fully analyse the project requirements and make an assessment of how to achieve it using the most appropriate technology).

    What it comes down to is that JavaScript alone cannot do what you want. You'd need to involve a server-side language to process the internal search from your Joomla database. You've said your site is already doing that and being as you want the internal Joomla search engine to be integrated so that the one form generates internal and external Yahoo results, it would make sense to work with the existing form/search as a base and use the language that Joomla does, which is PHP, to do any additional processing.

    So in order for anybody to help you, they would need;

    1 - Ideally, a link to your website with the search box (to check markup and the behaviour of the form)

    2 - A copy of the Joomla search form template file (to make markup changes, adding required checkboxes, etc)

    3 - A copy of the Joomla form processing script (PHP: to pass through the new checkbox variables, to add conditions that process "internal", "external" or "both" selection, etc)

    4 - A copy of the Joomla search results page generation script (PHP: to make use of the variables and conditional results gained in point 3 - this may be the same file as mentioned in point 3)

    5 - A copy of the Joomla search results page template file (use PHP to insert JavaScript that performs the Yahoo search and write the iframes, if required, based on selection variables and keyword variables passed from the form)

    Quote Originally Posted by Elizabet View Post
    Knowlege of Joomla is not required at all in this
    Anybody with the appropriate PHP and JavaScript experience would be able to help you if you could provide those files, but knowledge of Joomla would be beneficial to speed up the process, otherwise you'd be relying on a Joomla-virgin developer to spend time locating the pertinent scripts/files and initially understanding the code - possible needing to digest underlying functions, classes, and constructs (all located in other files) that are unique to the Joomla code base - and that's a lots to ask in a free forum. Of course you could pay somebody, and again, here a Joomla-experienced developer would be an advantage and easier on your pocket. In using a Joomla-virgin developer you'd be partially paying for them to learn on the job, which would not be as cost effective for you.

    So Joomla knowledge is as advantage in completing your project.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  9. #9
    Join Date
    Jun 2015
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank You Beverlyh,

    My website is not yet online but the behavior of its internal search will be exactly like that of the official joomal website. And the following url of the official Joomla will show you how the default joomla search engine works
    http://www.joomla.org/component/search/?searchword=CODE
    "CODE" at the end of the url is the keyword that was entered into the Joomla default search box.

    The reason I said knowlege of Joomla would not be needed is, I thought one would not need to understand the server-side language of Yahoo Search engine in order to pass the query strings to fetch its results. That is to say, fetching results from Yahoo database is much similar to fetching search results from Joomla database as url variable is basically what is needed in both cases

    * CODE is the keyword
    JOOMLA search url is http://www.joomla.org/component/search/?searchword=CODE. Page opened by this url shows the search results relating to the keyword CODE. So I want this page in iframe1
    YAHOO search url is http://search.yahoo.com/search?p=CODE. Page opened by this url shows results relating to the keywork CODE. So I want this page in iframe2

    Next I want Iframe1 and iframe2 beside each other.

    I am new to coding which is why maybe I thought this is a simple work. I very much appreciate your time and effort explaining things to me. Thanks once again

Similar Threads

  1. Software or Script to Search a Website for a Given Search String and Provide Report
    By fergusoncg in forum Looking for such a script or service
    Replies: 5
    Last Post: 11-14-2013, 01:39 AM
  2. Replies: 0
    Last Post: 04-06-2008, 07:57 PM
  3. Replies: 15
    Last Post: 03-03-2007, 08:42 AM
  4. Yahoo Search Menu
    By webtrader in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 06-16-2005, 03:31 AM
  5. Website Search Box
    By Ch3vr0n in forum JavaScript
    Replies: 7
    Last Post: 02-09-2005, 10:36 AM

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
  •