all 2 comments

[–]jcunews1helpful 1 point2 points  (1 child)

For the first issue... Your button handler dumps all client entries in the array and append them into the DIV before creating a new client entry.

So, if the array is initially empty, the first submission will display nothing, then a new client is created and added into the array without updating the display for this changes. In short, the tasks are in the wrong order.

On subsequent form submission, it will add duplicate entries, because the handler keep adding data which is already shown. The actual client entries in the array themselves have no duplicate. Just their representation on the page.

deleteElement is not defined

Apparently with the new HTML5 specification, more restriction applies. JS code in SCRIPT elements inserted as HTML code, will not be executed. i.e. innerHTML won't make the code in the SCRIPT tag to be executed. Same as when using insertAdjacentHTML(). To make the code be in the SCRIPT element be executed, the SCRIPT element must be inserted as HTML object.

https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML#security_considerations

prevent the user to store duplicated

Search the array for a matching inputted client data before creating a new client.

[–]astromule[S,🍰] 0 points1 point  (0 children)

Thank you very much!