Skip to content

Commit 08d7990

Browse files
committed
complete
1 parent ee54022 commit 08d7990

1 file changed

Lines changed: 37 additions & 7 deletions

File tree

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,49 @@
11
<!doctype html>
2-
2+
<html>
33
<head>
44
<meta charset="utf-8">
55
<script>
6-
// TODO: create a handler
7-
window.addEventListener("load", function(){
8-
// TODO: register the handler
9-
});
6+
window.addEventListener("load", function(){
7+
document.getElementById("searchForm").addEventListener("submit", function(event){
8+
event.preventDefault();
9+
10+
const selectedEngine = document.querySelector('input[name="engine"]:checked').value;
11+
12+
const actions = {
13+
"google": "https://www.google.com/search",
14+
"duckDuckGo": "https://duckduckgo.com/",
15+
"bing": "https://www.bing.com/search",
16+
"ask": "https://www.ask.com/web"
17+
};
18+
19+
this.action = actions[selectedEngine];
20+
21+
this.method = 'get';
22+
23+
this.submit();
24+
});
25+
});
1026
</script>
1127
</head>
12-
1328
<body>
1429

1530
<form id="searchForm">
16-
<!-- TODO: add form elements -->
31+
<input type="text" name="q" placeholder="Search...">
32+
<div>
33+
<input type="radio" id="google" name="engine" value="google" checked>
34+
<label for="google">Google</label>
35+
36+
<input type="radio" id="duckDuckGo" name="engine" value="duckDuckGo">
37+
<label for="duckDuckGo">DuckDuckGo</label>
38+
39+
<input type="radio" id="bing" name="engine" value="bing">
40+
<label for="bing">Bing</label>
41+
42+
<input type="radio" id="ask" name="engine" value="ask">
43+
<label for="ask">Ask</label>
44+
</div>
45+
<input type="submit" value="Go!">
1746
</form>
1847

1948
</body>
49+
</html>

0 commit comments

Comments
 (0)