Texts: HTML EXERCISE. I POSTED THIS QUESTION BEFORE BUT DIDN'T GET THE CORRECT ONE, PLEASE DO NOT COPY OTHER PEOPLE'S ANSWERS. THANK YOU!
(0) Import the js file I provided (sorry, Chegg doesn't allow me to upload the .js file, just pretend you have it). The file contains a shorter list of the most common baby names in the U.K. Insert <table id="name_table"></table> under the body.
(1) Use a loop, getElementById(), createTextNode(), createElement(), and appendChild() to create a table with the names. You may use HTML tags and innerHTML to finish the rest of the requirements of this note.
(2) Show how many names are there in the table.
(3) Create an input area for users to input their first name and last name. And ask the users to separate the first name and last name by a space.
(4) Validate that there is only one first name and one last name in the input. If the input does not meet the requirements, show alert("Wrong input").
(5) If the name passed the validation of step 4, insert the first name into the table and update the total number of all names.
(6) Use setAttribute to set the border of the table = 1.
(7) When users copy any name from the table, show the following alert: "NAME is copied!!"
The output is supposed to look like this:
Use a space to separate
Add a name
Andy Wang 16 names in the table
Add a name.
14 names in the table
Names
Names
David John Paul
David
John Paul Mark
Mark
James
James
Andrew
Andrew
Scott Steven Robert
Scott
Steven Robert
Stephen William Craig Michael Stuart
Stephen William Craig Michael Stuart
J
Andy