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
45 lines (37 loc) · 1.26 KB
/
index.html
File metadata and controls
45 lines (37 loc) · 1.26 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
42
43
44
45
<!doctype html>
<head>
<meta charset="utf-8">
<script>
function setSearchEngine(){
let form = document.getElementById("searchForm")
let actions = {
"google": "https://www.google.com/search",
"duckDuckGo": "https://duckduckgo.com/",
"bing": "https://www.bing.com/search",
"ask": "https://www.ask.com/web"
}
let search = document.querySelector("input[name=engine]:checked");
let input = document.querySelector("input[name=q]").value;
let actionURL=actions[search.value];
form.setAttribute("action", actionURL);
if (input === null){
}
};
window.addEventListener("load", function(){
let form = document.getElementById("searchForm")
//let submit = document.getElementById("submit");
form.addEventListener("submit", setSearchEngine);
//event.preventDefault();
});
</script>
</head>
<body>
<form id="searchForm">
<input type="text" name="q"/>
<label><input type="radio" name="engine" id="google" value="google">Google</label>
<label><input type="radio" name="engine" id="duckDuckGo" value="duckDuckGo">Duck Duck Go</label>
<label><input type="radio" name="engine" id="bing" value="bing">Bing</label>
<label><input type="radio" name="engine" id="ask" value="ask">Ask</label>
<button id="submit">Go!</button>
</form>
</body>