-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathindex.html
More file actions
53 lines (46 loc) · 1.3 KB
/
index.html
File metadata and controls
53 lines (46 loc) · 1.3 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
<!doctype html>
<head>
<meta charset="utf-8">
<title>
HTTP AND FORM
</title>
<script >
function setSearchEngine(){
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 form=document.getElementById('searchForm');
let buttonSelected=document.querySelector('input[name=engine]:checked')
let query=document.getElementById('q');
// let errorBox=document.getElementById("errorBox")
// let errorMsg=document.getElementById("errorMsg")
// if(!buttonSelected){
// }
let urll=actions[buttonSelected.value];
form.action=urll;
}
window.addEventListener("load", function(){
// TODO: register the handler
let form=this.document.getElementById('searchForm');
form.addEventListener("submit",setSearchEngine);
});
</script>
</head>
<body>
<form id="searchForm" action="">
<!-- TODO: add form elements -->
<input type="text" name="q" />
<input type="radio" name="engine" value="google"/>
<label>Google</label>
<input type="radio" name="engine" value="duckDuckGo"/>
<label>DuckDuckGo</label>
<input type="radio" name="engine" value="bing"/>
<label>Bing</label>
<input type="radio" name="engine" value="ask"/>
<label>Ask</label>
<button > Go!</button>
</form>
</body>