Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 863231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:16:37+00:00 2026-05-15T09:16:37+00:00

i’m developing a meta search engine website, Soogle and i’ve used JS to populate

  • 0

i’m developing a meta search engine website, Soogle and i’ve used JS to populate select menu..

Now, after the page is loaded none of engines is loaded by default, user needs to select it on his own or [TAB] to it..

Is there a possibility to preselect one value from the menu via JS after the page loads?

This is the code:

Javascript:

// SEARCH FORM INIT
function addOptions(){
    var sel=document.searchForm.whichEngine;
    for(var i=0,l=arr.length;i<l;i++){
        sel.options[i]=new Option(arr[i][0], i);
    }
}

function startSearch(){
    var searchString=document.searchForm.searchText.value;
    if(searchString.replace(/\s+/g,"").length > 0){
        var searchEngine=document.searchForm.whichEngine.selectedIndex,
            finalSearchString=arr[searchEngine][1]+searchString;
        window.location=finalSearchString;
    }
    return false;
}
function checkKey(e){
    var key = e.which ? e.which : event.keyCode;
    if(key === 13){
        return startSearch();
    }
}

// SEARCH ENGINES INIT
var arr = [
    ["Web", "http://www.google.com/search?q="],
    ["Images", "http://images.google.com/images?q="],
    ["Knowledge","http://en.wikipedia.org/wiki/Special:Search?search="],
    ["Videos","http://www.youtube.com/results?search_query="],
    ["Movies", "http://www.imdb.com/find?q="],
    ["Torrents", "http://thepiratebay.org/search/"]
];

HTML:

<body onload="addOptions();document.forms.searchForm.searchText.focus()">

<div id="wrapper">
<div id="logo"></div>

<form name="searchForm" method="POST" action="javascript:void(0)">
<input name="searchText" type="text" onkeypress="checkKey(event);"/>
<span id="color"></span>
<select tabindex="1" name="whichEngine" selected="Web"></select>
<br />
<input tabindex="2" type="button" onClick="return startSearch()" value="Search"/>
</form>
</div>

</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:16:38+00:00Added an answer on May 15, 2026 at 9:16 am

    I appreciate that your question asks for a solution that utilises JavaScript, but having looked at the webpage in question I feel confident in making this point:

    Your problem is that you are trying to use JavaScript for something that HTML itself was designed to solve:

    <select name="whichEngine">
        <option value="http://www.google.com/search?q=" selected="selected">Web</option>
        <option value="http://images.google.com/images?q=">Images</option>
        <option value="http://en.wikipedia.org/wiki/Special:Search?search=">Knowledge</option>
        <option value="http://www.youtube.com/results?search_query=">Videos</option>
        <option value="http://www.imdb.com/find?q=">Movies</option>
        <option value="http://thepiratebay.org/search/">Torrents</option>
    </select>
    

    Fear not, though! You can still access all of the options from JavaScript in the same way that you did before.

    function alertSelectedEngine() {
        var e = document.getElementsByName("whichEngine")[0];
        alert("The user has selected: "+e.options[e.selectedIndex].text+" ("+e.options[e.selectedIndex].value+")");
    }
    

    Please, forgive and listen to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.