Skip to content

Finished studio #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# HTTP-and-Forms-Studio
Launchcode studio
56 changes: 51 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,65 @@
<!doctype html>

<head>
<title>HTTP and Forms Studio</title>
<meta charset="utf-8">
<script>
// TODO: create a handler
window.addEventListener("load", function(){
// TODO: register the handler
});


const ENGINES_URLS = {
google: 'https://www.google.com/search',
duckDuckGo: 'https://duckduckgo.com/',
bing: 'https://www.bing.com/search',
ask: 'https://www.ask.com/web'
};

window.addEventListener("load", function () {

let engines = document.querySelectorAll('input[type=radio]');
engines.forEach(engine => {
engine.onclick = function () {
let url = ENGINES_URLS[engine.value];
if (url) searchForm.setAttribute('action', url);
console.log('>Form.action ', url);
};
});


});
</script>
<style>
body {
text-align: center;
font-size: 1.5em;
}

form {
padding: 0em;
margin: 0 auto;
}

form>* {
vertical-align: middle;
line-height: 1.5em;
}

button {
font-weight: bold;
margin: auto 5px;
}
</style>
</head>

<body>

<form id="searchForm">
<!-- TODO: add form elements -->
<input type="text" id="q" name="q" required>
<input type="radio" name="engine" id="engine1" value="google" required><label for="engine1">Google</label>

<input type="radio" name="engine" id="engine2" value="duckDuckGo"><label for="engine2">DuckDuckGo</label>
<input type="radio" name="engine" id="engine3" value="bing"><label for="engine3">Bing</label>
<input type="radio" name="engine" id="engine4" value="ask"><label for="engine4">Ask</label>
<button type="submit">Go!</button>
</form>

</body>