Home : Internet : JavaScript : Multiple Search : Radio Buttons

Multi-Search Form With Radio Buttons

This page shows how to make a multi-search form using radio buttons. The principle is the same as the drop-menu search form. We also have another variation using thumbnail images.

Search:
Google
Alta Vista
Dogpile
Yahoo!
For:

Function Code

Place this code in the page head:

<script type="text/javascript">
function dosearch() {
var sf=document.searchform;
for (i=sf.sengines.length-1; i > -1; i--) {
if (sf.sengines[i].checked) {
var submitto = sf.sengines[i].value + escape(sf.searchterms.value);
}
}
window.location.href = submitto;
return false;
}
</script>

Form Code

This is the code for the form (customise as required):

<form name="searchform" onSubmit="return dosearch();">
Search:<br />
<input name="sengines" type="radio" value="http://www.google.com/search?q="> Google<br />
<input name="sengines" type="radio" value="http://www.altavista.com/web/results?q="> Alta Vista<br />
<input name="sengines" type="radio" value="http://www.dogpile.com/info.dogpl/search/web/"> Dogpile<br />
<input name="sengines" type="radio" value="http://search.yahoo.com/search?p="> Yahoo!<br />
For:
<input type="text" name="searchterms">
<input type="submit" name="SearchSubmit" value="Search">
</form>