Skip to content

Commit b66daeb

Browse files
committed
completed studio
1 parent c3343b4 commit b66daeb

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

user-input-with-forms/studio/index.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,34 @@
33
<head>
44
<meta charset="utf-8">
55
<script>
6-
// TODO: create a handler
6+
function setSearchEngine() {
7+
document.getElementById('searchForm').setAttribute("action", actionsURL[document.querySelector("input[name=engine]:checked").value]);
8+
return;
9+
};
710
window.addEventListener("load", function(){
8-
// TODO: register the handler
11+
let button = document.getElementById("goButton");
12+
button.addEventListener("click", setSearchEngine);
913
});
14+
let actionsURL = {
15+
google: 'https://www.google.com/search',
16+
duckduckgo: 'https://duckduckgo.com/',
17+
bing: 'https://www.bing.com/search',
18+
ask: 'https://www.ask.com/web'
19+
};
20+
let searchForm = document.getElementById('searchForm');
21+
searchForm.setAttribute("action", );
1022
</script>
1123
</head>
1224

1325
<body>
1426

1527
<form id="searchForm">
16-
<!-- TODO: add form elements -->
28+
<label>name<input type="text" name="q"></label>
29+
<label>Google<input value="google" type="radio" name="engine"></label>
30+
<label>DuckDuckGo<input value="duckduckgo" type="radio" name="engine"></label>
31+
<label>Bing<input value="bing" type="radio" name="engine"></label>
32+
<label>Ask<input value="ask" type="radio" name="engine"></label>
33+
<button id="goButton" value="Go!">Go!</button>
1734
</form>
1835

1936
</body>

0 commit comments

Comments
 (0)