0

bug, button not working

https://code.sololearn.com/WrZ7UYMr9yw3/#js this is a link to a code I've written. when you select from the list and hit 'submit' it has to create an 2 elements. but it doesn't do it. please help

1/25/2020 6:49:13 AM

Youssef Alaa

5 Answers

New Answer

+3

Sorry, din't notice that... I just dint read his JS code

+2

The attribute onclick has not been added to your button. You need to add tge attribute to fire in the function when the button is clicked. <button onclick="FuncName()">TextEg</button> Happy coding 😉 Keep coding 🙏🏾

+2

Alfred Juma There's no need to use onclick in HTML, he used it in the JS and the event listener actually works fine. Actually, this if (this.inputSetup === '') in the setup function causes the problem. If you'd like to check whether this.inputSetup is undefined you should probably use if (this.inputSetup === null) or if (this.inputSetup === undefined). At least it's clear that the setup function gets stuck on that if clause, so you might comment it out, too, until you checked the functionality of the rest of the code.

+1

Youssef Alaa ok, sorry, I might have misunderstood the purpose of the if statement. I still don't know, what it does but if you remove it, you can change line 25 to mergePlace.appendChild(newElement); and the code works.

0

Aaron Eberhardt, I just tried checking for null and undefined but it didn't work.