Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15
  1. #11
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    Sorry I missed your other post there Jussi.

    There is no way to display all the results on one page with JavaScript, as the code simply sends a request to each search engine. The results are generated by the search engine in question, not by the JavaScript.

    A way around this would be to create a page with multiple frames and have each SE result page show in a different frame. Personally I would be wary of such a solution (I don't think it would be very robust) but if you're keen to give it a try it would be interesting.

    If you really want the frames thing and you can't manage it yourself, let me know and I might see if I can give it a quick try. It will be after Christmas though - too much to do today.
    Dave Owen
    MediaCollege.com

  2. #12
    Jussi
    Guest
    Dave,

    Hope You had merry Christmas!

    I have managed to write some idiot code which enables to make search on ALL the prelisted search engines at one press of a button.

    var submitto1 = "http://www.google.com/search?q=" + escape(sf.searchterms.value);
    window.open(submitto1);
    var submitto2 = "http://search.msn.com/advresults.aspx?q=" + escape(sf.searchterms.value);
    window.open(submitto2);
    var submitto3 = . . .

    Of course, this opens as many new windows as there are SE:s listed, so it's not very sophisticated script.

    But do you have any idea how to modify the following line to make search only on selected but multiple SE:s (see my html-code earlier in thread 30th Nov):

    var submitto = sf.sengines.options[sf.sengines.selectedIndex].value + escape(sf.searchterms.value);

    Thanks,
    /jussi

  3. #13
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    Merry Christmas etc to you too

    Javascript can't detect multiple selections easily - you have to create an array and use that. Try the following code and see how you get on....

    Code:
    <script language="JavaScript">
    function dosearch() {
    
    var selectedArray = new Array();
    var selObj = document.getElementById('sengines');
    var i;
    var count = 0;
    for (i=0; i<selObj.options.length; i++) {
    	if (selObj.options[i].selected) {
    	  selectedArray[count] = selObj.options[i].value;
    	  count++;
    	}
    }
    
    if (selectedArray[0]) {
    	var submitto1 = selectedArray[0] + escape(sf.searchterms.value);
    	window.open(submitto1);
    	}
    if (selectedArray[1]) {
    	var submitto2 = selectedArray[1] + escape(sf.searchterms.value);
    	window.open(submitto2);
    	}
    if (selectedArray[2]) {
    	var submitto2 = selectedArray[2] + escape(sf.searchterms.value);
    	window.open(submitto2);
    	}
    if (selectedArray[3]) {
    	var submitto3 = selectedArray[3] + escape(sf.searchterms.value);
    	window.open(submitto3);
    	}
    return false;
    }
    </script>
    
    <!-- HTML Form -->
    <form name="searchform" onSubmit="return dosearch();">
    Search: 
    <select name="sengines" size="4" id="sengines" multiple>
    <option value="http://www.google.com/search?q=" selected>Google</option>
    <option value="http://www.altavista.com/web/results?q=">Alta Vista</option>
    <option value="http://www.dogpile.com/info.dogpl/search/web/">Dogpile</option>
    <option value="http://search.yahoo.com/search?p=">Yahoo!</option>
    </select>
    For: 
    <input type="text" name="searchterms">
    <input type="submit" name="SearchSubmit" value="Search">
    </form>
    I'm not sure how this will go in IE - it would only open one window when I tested it. It worked in Firefox though. Let me know how you get on.
    Note: I've used an ID for the select this time (id="sengines") for better Firefox compatibility.
    Dave Owen
    MediaCollege.com

  4. #14
    Jussi
    Guest
    Thank You, Dave,

    But: instead of getting any search result window, e.g. selecting Google I get this line to browser's url line, both IE and Firefox.

    http://mysite/mysearchpage?sengines=...hSubmit=Search

    What might be wrong?

    /jussi

  5. #15
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    Can you show us the URL of the search form?
    Dave Owen
    MediaCollege.com

Page 2 of 2 FirstFirst 12

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