Create the nameSearch variable equal to the value entered in the nameSearch input box. Users can search for names in three ways: Matching an employee's last name if it contains the text string specified in nameSearch Matching an employee's last name if it begins with the nameSearch text string Matching an employee's last name only if it exactly matches the nameSearch text string. Richard has supplied you with code to add the selectedValue() method to the prototype of the HTMLSelectElement object class in order to return the value of the selected option in any selection list. Apply the selectedValue() method to the nameSearchType selection list to return the option selected by the user, storing the value in the nameSearchType variable. Create a switch-case structure for the following possible values of the nameSearchType

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

(this question is part 2 of 3 in a long problem)

JavaScript Commands

Create the nameSearch variable equal to the value entered in the nameSearch input box.

Users can search for names in three ways:

  1. Matching an employee's last name if it contains the text string specified in nameSearch
  2. Matching an employee's last name if it begins with the nameSearch text string
  3. Matching an employee's last name only if it exactly matches the nameSearch text string.

Richard has supplied you with code to add the selectedValue() method to the prototype of the HTMLSelectElement object class in order to return the value of the selected option in any selection list. Apply the selectedValue() method to the nameSearchType selection list to return the option selected by the user, storing the value in the nameSearchType variable.

Create a switch-case structure for the following possible values of the nameSearchType variable:

  1. If nameSearchType equals "contains", use the new RegExp() constructor to create a regular expression object named nameRegExp containing the regular expression nameSearch where nameSearch is the value of the nameSearch variable. Include the "i" flag with the regular expression object so that the regular expression matches lower or uppercase characters.
  2. If nameSearchType equals "beginsWith", set nameRegExp object to the regular expression ^nameSearch, once again with the "i" flag.

If nameSearchType equals "exact", set nameRegExp object to the regular expression ^nameSearch$ with the "i" flag to allow for upper- and lower-case matches.

cc_staff.js (add code to this file)

/* Constructor function for the employee class */
function employee(id, firstName, lastName, dept, position, email, phone, photo) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.dept = dept;
this.position = position;
this.email = email;
this.phone = phone;
this.photo = photo;
}

/* Object literal for search results */
var searchResult = {
employees : [],
sortById:function() {
this.employees.sort(function(a,b) {
if (a.id < b.id) {return-1;}
else {return1;}
});
}
};


/* Event listener to retrieve and display employee records matching the search condition */
document.getElementById("searchButton").addEventListener("click", function() {
var tableBody = document.querySelector("table#staffTable tbody");
var tableCaption = document.querySelector("table#staffTable caption");

});








/* --- Methods added to native objects ---*/

/* Method added to any DOM element that removes all child nodes of element */
HTMLElement.prototype.removeChildren = function() {
while (this.firstChild) {
this.removeChild(this.firstChild);
}
};

/* Method added to the select element to return the value of the selected option */
HTMLSelectElement.prototype.selectedValue = function() {
var sIndex =this.selectedIndex;
returnthis.options[sIndex].value;
};

 

ADVOCACY
COMPLIANCE DEVELOPMENT
COMMUNITY
NEWS
SUPPORT
NEWSLETTER
CRESCENT CREDIT UNION LEAGUE
Staff Directory
Last Name
M
Begins With
Department
Position
director
Contains
search
3 records found
PHOTO
NAME
DEPARTMENT
PO SITION
E-MAIL
PHONE
Betty Moran
Professional Development
Director of Meetings & Conferences
betty.moran@ccul.example.com
B0D-555-6506
Douglas Moorman
Audit Services
Director of Comprehensive Audits
douglaz.moorman@ccul.example.com
B00-555-9019
Steven Miller
PR and Communications
Director of Communications
steven-millen@ccul.example.com
B0D-555-5505
ADVOCACY
COMPLIANCE
DEVELOPMENT
COMMUNITY
Deadlines & Policies
Regulatory Deadlines
Compliance FAQ
Fraud & Risk Resources
Annual Meeting
Leadership Institute
Webinars
Grass Roots Action
Chapters
Asset Groups
CCUL History
Membership Info
Social Media
Federal Issues
Research & Resources
Regulatory Report
Training
Compliance Group
Certification
CCUL Magazine
Call Center
Events
Advocacy Team
Board of Directors
Crescent Credit Union League © 2018 All Rights Reserved
Transcribed Image Text:ADVOCACY COMPLIANCE DEVELOPMENT COMMUNITY NEWS SUPPORT NEWSLETTER CRESCENT CREDIT UNION LEAGUE Staff Directory Last Name M Begins With Department Position director Contains search 3 records found PHOTO NAME DEPARTMENT PO SITION E-MAIL PHONE Betty Moran Professional Development Director of Meetings & Conferences betty.moran@ccul.example.com B0D-555-6506 Douglas Moorman Audit Services Director of Comprehensive Audits douglaz.moorman@ccul.example.com B00-555-9019 Steven Miller PR and Communications Director of Communications steven-millen@ccul.example.com B0D-555-5505 ADVOCACY COMPLIANCE DEVELOPMENT COMMUNITY Deadlines & Policies Regulatory Deadlines Compliance FAQ Fraud & Risk Resources Annual Meeting Leadership Institute Webinars Grass Roots Action Chapters Asset Groups CCUL History Membership Info Social Media Federal Issues Research & Resources Regulatory Report Training Compliance Group Certification CCUL Magazine Call Center Events Advocacy Team Board of Directors Crescent Credit Union League © 2018 All Rights Reserved
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

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