Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Test Page</title>
<style>
  body {
    font-family: sans-serif;
  }
</style>
</head>
<body>
<form name="searchForm" action="" method="GET" onSubmit="return doSearch()">
<input type="text" name="keyword">
  <br>
  <label>Google<input type="radio" name="ch" value="google" checked></label>
  <label>Yahoo!<input type="radio" name="ch" value="yahoo"></label>
  <label>Bing<input type="radio" name="ch" value="bing"></label>
  <br>
  <input type="submit" value="Search">
</form>
</body>
</html>
 
var searchengine = {
  "google": "http://google.com/search?q=",
  "yahoo": "http://search.yahoo.com/search?p=",
  "bing": "http://bing.com/search?q="
};
function doSearch() {
  var frm, index, cb;
  
  frm = document.searchForm;
  if (frm && frm.ch) {
    if (frm.ch) {
      for (index = 0; index < frm.ch.length; ++index) {
        cb = frm.ch[index];
        if (cb.checked) {
          window.location = searchengine[cb.value] +
            encodeURIComponent(frm.keyword.value);
        }
      }
    }
  }
  
  return false; // Cancels form submission
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers