Click to See Complete Forum and Search --> : Fake Submit button


rav
08-26-2003, 08:49 AM
I have a few select options and a few input buttons. What I want to have is the searchGoNow function to execute when "Enter" is pressed and the user is Focused on the form.

Here's what I have:

<select id="dropdown1" name="dropdown">
<option value="http://142.70.4.58/bluebook/searchresult.asp?search=&amp;name=" selected >Blue Book</option>
<option value="http://intraapps.noranda.com/phone_book/search_results.asp?search=&amp;name=" >Falconbridge Phonebook</option>
<option value="http://www.google.com/search?q=" >Google</option>
<option value="http://search.yahoo.com/bin/search?p=">Yahoo</option>
<option value="http://search.excite.com/search.gw?search=">Excite</option>
</select>

<input id="criteria" name="criteria">
<input type="button" value="Go" id="submit1" name="submit1" onclick="searchGoNow(dropdown.value,criteria.value);">

<SCRIPT LANGUAGE=javascript>
<!--
function searchGoNow(url,criteria)
{
if (criteria == "")
alert ("Please enter your search criteria and try again!!");
else
{
window.open(url + criteria, 'Search')
}
return false;
}
-->
</SCRIPT>

AdamBrill
08-26-2003, 10:20 AM
Try this:<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
function searchGoNow(url,criteria){
if (criteria == "")
alert ("Please enter your search criteria and try again!!");
else {
window.open(url + criteria, 'Search')
}
return false;
}
-->
</script>
</head>
<body>
<form onsubmit="searchGoNow(dropdown.value,criteria.value); return false;">
<select id="dropdown1" name="dropdown">
<option value="http://142.70.4.58/bluebook/searchresult.asp?search=&name=" selected >Blue Book</option>
<option value="http://intraapps.noranda.com/phone_book/search_results.asp?search=&name=" >Falconbridge Phonebook</option>
<option value="http://www.google.com/search?q=" >Google</option>
<option value="http://search.yahoo.com/bin/search?p=">Yahoo</option>
<option value="http://search.excite.com/search.gw?search=">Excite</option>
</select>
<input id="criteria" name="criteria">
<input type="submit" value="Go" id="submit1" name="submit1">
</form>
</body>
</html>