Finally, add a table row to the body of the staff table: one row for each employee record. Apply the forEach() method to employees array in the searchResult object and for each record in the array, append the following document fragment to the tableBody object first last dept position email phone where photo, first, last, dept, position, email, and phone are the values of the photo, firstName, lastName, dept, position, email, and phone property of the current record in the employees array of the searchResult object.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

F/u from first question.

Using nameRegExp as the regular expression, apply the test() method to the record.Lastname property (the last name stored in the employee record currently being examined in the forEach() loop). Store the results of the test() method in the foundName variable.

Repeat the previous instructions in this step (starting with the Create the nameSearch... instruction and ending with the Using nameRegExp... instruction) to determine whether the employee's position property matches the value entered into the positionSearch input box on the web form. Store the value of the positionSearch input box in the positionSearch variable, the type of search in the positionSearchType variable, the regular expression in the positionRegExp variable, and the result of the regular expression test in the foundPosition variable.

The final search condition in the web form allows the user to specify the employee's department. Users can leave the department blank (to match any department) or they can specify the department from the deptSearch selection list.

Apply the selectedValue() method that Richard created for select elements to the deptSearch selection list to retrieve the department value selected by the user, storing the value in the deptSearch variable. If deptSearch equals "" or the value of record.dept (the value of the dept property for the current employee record currently being examined in the forEach() loop), store the Boolean value true in the deptFound variable.

For an employee record to be displayed in the staff table, it must match the search condition set by the user. Insert an if statement that tests whether foundName, foundPosition, and foundDept are all true. If so, use the push() method to add a new employee object to the employees array in the searchResult object. (Hint: use record.id, record.firstName, record.lastName, and so on as the parameter values in the new employee() statement.)

After the forEach loop has finished and the employees array in the searchResult object contains all of the employee records matching the user’s search conditions, change the text content of the tableCaption object to "numRecords records found" where numRecords is the value of the length of the employees array in the searchResult object.

Apply the sortById() method to the searchResult object, which will sort the content of the employees array by the employee ID number.

  1. Finally, add a table row to the body of the staff table: one row for each employee record. Apply the forEach() method to employees array in the searchResult object and for each record in the array, append the following document fragment to the tableBody object
  2. <tr>
  3. <td><img src="photo" /></td>
    <td>first last</td>
    <td>dept</td>
    <td>position</td>
    <td><a href="mailto:email">email</a></td>
    <td><a href="tel:phone">phone</a></td>
    </tr>

  4. where photo, first, last, dept, position, email, and phone are the values of the photo, firstName, lastName, dept, position, email, and phone property of the current record in the employees array of the searchResult object.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY