0
Please help, anyone there to figure out the solution to this code error(display of undefined) in the selection menu...
12 Answers
+ 2
Just change the event type for line 43 to "change" and it will fix it.
filterOption.addEventListener("change",filterTodo);
+ 3
Try this;
function filterTodo(event){
const todos = todoList.children;
for(let i = 0; i < todos.length; i++) {
switch(event.target.value){
case "all":
todos[i].style.display = "flex";
break;
case "completed":
if(todos[i].classList.contains("completed")){
todos[i].style.display = "flex";
}
else{
todos[i].style.display = "none";
}
break;
case "uncompleted":
if(!todos[i].classList.contains("completed")){
todos[i].style.display = "flex";
}else{
todos[i].style.display = "none";
}
break;
}
}
}
+ 2
Thanks alot "ChaoticDawg" it worked fine now,
well done brođđŒ!
+ 2
Samuel Mathew ya that was the 1 I was talking about that I missed. You need to add [i] after todos in the if statement, like all the others have for the index of todos.
+ 2
Yeah! I just noticed that now...
+ 1
Actually, you can just change this 1 line
const todos = Array.from(todoList.childNodes).slice(1);
Then it should work, but you still have a bug.
+ 1
I see you changed it to my 1st post.
I missed 1 on line 104, so, if you're going to use this version make sure you fix it too.
+ 1
Okay I got it now, thanks bro.
+ 1
FYI, you need to make this function fire on item selected instead of the click. That should fix the behavior bug that it currently has.
+ 1
Done, now it works fine, thanks bro...
0
When i looked just now, there isn't an error. Did you find the solution?
0
How can I do that, is there still bug in the code...