Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have modified the code to use jQuery. It is working fine in IE8, IE8 (Compatibility mode) and in FireFox.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head id="Head1" runat="server"&gt; &lt;title&gt;Index&lt;/title&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // SEARCH ENGINES INIT var arr = new Array(); arr[arr.length] = new Array("Web", "http://www.google.com/search?q="); arr[arr.length] = new Array("Images", "http://images.google.com/images?q="); arr[arr.length] = new Array("Knoweledge", "http://en.wikipedia.org/wiki/Special:Search?search="); arr[arr.length] = new Array("Videos", "http://www.youtube.com/results?search_query="); arr[arr.length] = new Array("Movies", "http://www.imdb.com/find?q="); arr[arr.length] = new Array("Torrents", "http://thepiratebay.org/search/"); // SEARCH FORM INIT function addOptions() { // Add the options to the select dropdown. var nOptions = arr.length; var optionText = ''; for (var i = 0; i &lt; nOptions; i++) { optionText += '&lt;option value="' + i + '"&gt;' + arr[i][0] + '&lt;/option&gt;' } //alert('optionText = ' + optionText); // Add the options to the select drop down. $('select#whichEngine').html(optionText); // set the second option as default. This can be changed, if required. $('select#whichEngine option:eq(1)').attr('selected', true); } function startSearch() { var searchEngineIndex = $('select#whichEngine option:selected').attr('value'); searchEngineIndex = parseInt(searchEngineIndex, 10); var searchString = $('input#searchText').val(); if (searchEngineIndex &gt;= 0 &amp;&amp; searchString) { var searchURL = arr[searchEngineIndex][1] + searchString; //alert('location = ' + searchURL); window.location.href = searchURL; } return false; } function checkKey(e) { var character = (e.which) ? e.which : event.keyCode; if (character == '13') { return startSearch(); } } $(function() { // Add the options to the select drop down. addOptions(); // Add focus to the search text box. $('input#searchText').focus(); // Hook the click event handler to the search button. $('input[type=button]').click(startSearch); $('input#searchText').keyup(checkKey); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="wrapper"&gt; &lt;div id="logo"&gt;&lt;/div&gt; &lt;form name="searchForm" method="POST" action="javascript:void(0)"&gt; &lt;input id="searchText" name="searchText" type="text"/&gt; &lt;span id="color"&gt;&lt;/span&gt; &lt;select tabindex="1" id="whichEngine" name="whichEngine"&gt;&lt;/select&gt; &lt;br /&gt; &lt;input tabindex="2" type="button"value="Search"/&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload