forked from LaunchCodeEducation/HTTP-and-Forms-Studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
41 lines (38 loc) · 1.35 KB
/
index.html
File metadata and controls
41 lines (38 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!doctype html>
<head>
<meta charset="utf-8">
<title>Search Engine Selector</title>
<link rel = "stylesheet" type = "text/css" href = "styles.css" />
<script>
window.addEventListener("load", function(){
let actions = {
google:"https://www.google.com/search",
duckduckgo:"https://duckduckgo.com/",
bing:"https://www.bing.com/search",
ask:"https://www.ask.com/web"
};
const searchform = document.getElementById("searchForm");
//const textinput = document.getElementById("textinput");
function setSearchEngine() {
const selectEngine = document.querySelector('input[name="engine"]:checked');
return actions[selectEngine.value];
}
searchform.addEventListener("submit", function(){
searchform.setAttribute('action', setSearchEngine());
});
});
</script>
</head>
<body>
<form method="GET" id="searchForm">
<div>
<label>Search:<input type="text" name="q" id="text-input"/></label>
<label>Google<input type="radio" name="engine" value="google"/></label>
<label>DuckDuckGo<input type="radio" name="engine" value="duckduckgo"/></label>
<label>Bing<input type="radio" name="engine" value="bing"/></label>
<label>Ask<input type="radio" name="engine" value="ask"/></label>
<button>Go!</button>
</div>
</form>
</body>
</html>