My code gives me the following error for the first function:
Uncaught ReferenceError: myFunction is not defined at HTMLButtonElement.onclick
I also get this error for the second function:
Uncaught ReferenceError: filterFunction is not defined at HTMLInputElement.onkeyup
I checked for answers and the most commonly given was "Select No wrap - bottom of <head>
in the "Load type" dropdown in the JavaScript settings."
I cant select this since I'm using a Duda widget builder and no classic development environment. Any ideas would be appreciated. Thanks a lot.
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show"); // Klicken zeigt bzw. verbirgt die Dropdown Liste
}
function filterFunction() {
var input, filter, ul, li, a, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
div = document.getElementById("myDropdown");
a = div.getElementsByTagName("a");
for (i = 0; i < a.length; i++) {
txtValue = a[i].textContent || a[i].innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
a[i].style.display = "";
} else {
a[i].style.display = "none";
}
}
if (event.key === 'Enter') {
console.log(ele.value);
}
}
<div class="dropdown3"><button onclick="myFunction()" class="dropbtn">Bereich</button><div id="myDropdown" class="dropdown-content"><input type="text" placeholder="Search.." id="myInput" onkeyup="filterFunction()"><a href="#pflege">Pflege</a><a href="#verwaltung">Verwaltung</a><a href="#gastro">Gastronomie</a><a href="#wäsche">Wäscherei</a></div></div>