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
48 lines (39 loc) · 1.43 KB
/
index.html
File metadata and controls
48 lines (39 loc) · 1.43 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
<!doctype html>
<head>
<meta charset="utf-8">
<script>
// TODO: create a handler
function setSearchEnging(event) {
let form = document.getElementById('searchForm')
let selected = document.quesrySelector("input[name-engine]:checked");
//console.log("FUNCTION setSearchEngine() IS RUNNING!");
//event.preventDefault();
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 actionURL = actions[selected.value];
form.setAttribute('action', actionURL);
};
window.addEventListener("load", function(){
let form = document.getElementById('searchForm')
form.addEventListener('submit', setSearchEngine);
};
//event.preventDefault();
// TODO: register the handler
});
</script>
</head>
<body>
<form id="searchForm">
<!-- TODO: add form elements -->
<input name = "q"> value ="Enter Search Term Here">
<label>Google<input id "googleOption" type = "radio" name = "engine" value="Google"></label>
<label>DuckDuckGo<input id "duckduckgoOption" type = "radio" name = "engine" value="DuckDuckGo></label>
<label>Bing<input id "bingOption" type = "radio" name = "engine" value="Bing" ></label>
<label>Ask<input id "askOption" type = "radio" name = "engine" value="Ask"></label>
<input type = "submit" value="Go!">Go!</button>
</form>
</body>