Skip to content

Commit ceee646

Browse files
committed
user input studio
1 parent 8ffdbf4 commit ceee646

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1+
12
<!doctype html>
23

34
<head>
45
<meta charset="utf-8">
56
<script>
7+
function setSearchEngine() {
8+
let button = document.querySelector("input[name=engine]:checked");
9+
console.log("set search engine");
10+
buttonValue = radioSelection.value;
11+
console.log(button.value);
12+
13+
let actions = {
14+
"Google": "https://www.google.com",
15+
"DuckDuckGo": "https://duckduckgo.com/",
16+
"Bing": "https://www.bing.com/search",
17+
"Ask": "https://www.ask.com/web"
18+
};
19+
20+
21+
document.getElementById("searchForm").setAttribute = actionURL;
22+
console.log(actions[buttonValue]);
23+
event.preventDefault();
24+
}
25+
626
// TODO: create a handler
727
window.addEventListener("load", function(){
828
// TODO: register the handler
29+
let form = document.querySelector("form");
30+
form.addEventListener("submit", setSearchEngine);
931
});
1032
</script>
1133
</head>
@@ -14,6 +36,12 @@
1436

1537
<form id="searchForm">
1638
<!-- TODO: add form elements -->
17-
</form>
39+
<input type="text" name="q"><text>
40+
<label1><input type="radio" name="engine" value="Google">Google</label1>
41+
<label1><input type="radio" name="engine" value="DuckDuckGo">DuckDuckGo</label1>
42+
<label1><input type="radio" name="engine" value="Bing">Bing</label1>
43+
<label1><input type="radio" name="engine" value="Ask">Ask</label1>
44+
<button type="submit">Go!</button>
45+
</form>
1846

1947
</body>

0 commit comments

Comments
 (0)