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
56 lines (51 loc) · 1.4 KB
/
index.html
File metadata and controls
56 lines (51 loc) · 1.4 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
46
47
48
49
50
51
52
53
54
55
56
<!doctype html>
<head>
<meta charset="utf-8">
<style>
label{
display:block;
}
</style>
<script>
// TODO: create a handler
function setSearchEngine()
{
let searchEngine = Document.querySelector('input[name="engine"]:checked');
if(SearchEngine.value === "Google")
{
actionURL = "https://www.google.com/";
}
else if(SearchEngine.value === "duckgo")
{
actionURL = "https://duckduckgo.com/";
}
else if(SearchEngine.value === "bing")
{
actionURL = "https://www.bing.com/";
}
else if(SearchEngine.value === "ask")
{
actionURL = "https://www.ask.com/web";
}
let form = document.querySelector("form");
form.setAttribute("action",actionURL.value);
//console.log("set search engine");
}
window.addEventListener("load", function(){
// TODO: register the handler
let form = document.querySelector("form");
form.addEventListener("submit",setSearchEngine);
});
</script>
</head>
<body>
<form id="searchForm">
<!-- TODO: add form elements -->
<input type="text" name="q"/>
<lable><b>Google</b><input type="radio" name="engine" value="Google"/></lable>
<lable><b>DuckDuckGo</b><input type="radio" name="engine" value="duckgo"/></lable>
<lable><b>Bing</b><input type="radio" name="engine" value="bing"/></lable>
<lable><b>Ask</b><input type="radio" name="engine" value="ask"/></lable>
<input type="submit" value="Go!"/>
</form>
</body>