I'm developing this webapp for my school. The page is supposed to filter entries by the url parameter "class". This works fine as far as i can tell, but when i try to change the filter it gives "TypeError: object is not a function". What am i doing wrong?
<html> <head> <TITLE>Cancelled lessons</TITLE> </head> <body> <script> function filter(text){ text = text.toLowerCase(); for (i=0;i<lessonList.length;i++){ if(lessonList[i].innerHTML.toLowerCase().indexOf(text)==-1){ lessonList[i].style.display = "none"; } else{ lessonList[i].style.display =""; } } } function gup( name ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; } </script> <form> Filter: <input type="text" id="filter" oninput="filter(document.getElementById('filter'))"/> </form> <div id="lessons"> <div class="entry"> MaA 11:00 C131 Ej NV3C</div> </div> <script> var lessonList = document.getElementsByClassName("entry"); var filterField =document.getElementById("filter"); filterField.value = gup("class"); filter(filterField.value); </script> </body> </html>