0

Please help, anyone there to figure out the solution to this code error(display of undefined) in the selection menu...

https://code.sololearn.com/WstAHwfAr5JW/?ref=app

18th Apr 2021, 7:30 AM
Samuel Mathew
Samuel Mathew - avatar
12 Antworten
+ 2
Just change the event type for line 43 to "change" and it will fix it. filterOption.addEventListener("change",filterTodo);
18th Apr 2021, 9:32 AM
ChaoticDawg
ChaoticDawg - avatar
+ 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; } } }
18th Apr 2021, 8:12 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Thanks alot "ChaoticDawg" it worked fine now, well done bro👍🏼!
18th Apr 2021, 8:48 AM
Samuel Mathew
Samuel Mathew - avatar
+ 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.
18th Apr 2021, 9:12 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Yeah! I just noticed that now...
18th Apr 2021, 9:15 AM
Samuel Mathew
Samuel Mathew - avatar
+ 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.
18th Apr 2021, 8:51 AM
ChaoticDawg
ChaoticDawg - avatar
+ 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.
18th Apr 2021, 8:55 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Okay I got it now, thanks bro.
18th Apr 2021, 9:12 AM
Samuel Mathew
Samuel Mathew - avatar
+ 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.
18th Apr 2021, 9:20 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Done, now it works fine, thanks bro...
18th Apr 2021, 11:27 AM
Samuel Mathew
Samuel Mathew - avatar
0
When i looked just now, there isn't an error. Did you find the solution?
18th Apr 2021, 7:53 AM
EO4Wellness
EO4Wellness - avatar
0
How can I do that, is there still bug in the code...
18th Apr 2021, 9:22 AM
Samuel Mathew
Samuel Mathew - avatar