-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
21 lines (17 loc) · 803 Bytes
/
script.js
File metadata and controls
21 lines (17 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const urlTrimmer = function(text) {
return encodeURIComponent(text)
}
//get the search box input to add to search url
const searchBox = document.querySelector("#searchform input");
document.getElementById("submit-button").addEventListener("click", function(searchRedirect) {
let searchValue= document.getElementById("userInput").value;
const redirectURL = `https://jay-zar.github.io/StarWarZ/redirect.html?keyword=`
urlAdd = urlTrimmer(searchValue);
const searchURL = redirectURL+urlAdd;
window.location.assign(searchURL);
})
document.getElementById("searchform").addEventListener('submit', (event) => {
// stop form submission and click invisible button instead
event.preventDefault();
document.getElementById("submit-button").click();
});