Skip to content

Commit

Permalink
Fixed event handler for input element
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobiasz Gala committed Oct 18, 2017
1 parent 6df976f commit bc710c5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ const arrStudentEmails = document.querySelectorAll(".student-details .email");
const studentList = studentContainer.children;
// number of all elements (students) on the page
const numOfItems = studentList.length;

// array which holds results of search function
let listArr = [];
// info message placeholder to display message to the user
let infoMessage;
// search input element
let searchInput;

// this function generates all elements needed for javascript functionality
function generateHTMLElements() {
Expand All @@ -24,7 +27,7 @@ function generateHTMLElements() {
// create div element for search function
let searchDiv = document.createElement('div');
// create search input
let searchInput = document.createElement('input');
searchInput = document.createElement('input');
// create info message placeholder
infoMessage = document.createElement('p');
// set class for search div
Expand Down Expand Up @@ -180,19 +183,14 @@ function searchElements(searchInput) {
}




// generate elements
generateHTMLElements();
// showButtons to display first page
showButtons(studentList);



// bind event listener to search input
document.querySelector(".student-search input").addEventListener('keyup', function() {
// get search input value
let searchValue = document.querySelector(".student-search input").value;
searchInput.addEventListener('keyup', function() {
// pass search input value in upper case for better results
searchElements(searchValue.toUpperCase());
})
searchElements(this.value.toUpperCase());
});

0 comments on commit bc710c5

Please sign in to comment.