Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The assignment is to basically just alter the volunteer.js file to be able to do what the assigment says to do below. For this assignment,

The assignment is to basically just alter the volunteer.js file to be able to do what the assigment says to do below.

For this assignment, you will use the volunteer.html file to create a more effective process for managing the volunteer list by using arrays and loops. The web application will make use of the volunteer.js file and allow the user to add volunteers, delete volunteers, clear the list of volunteers as well as sort the volunteers. Some of the functionality has been created to start you off so that you can see how it is all integrated. You will be focusing on the code to delete the volunteer as well as alter the volunteer list to add some formatting on the output. Functionality is also included to be able to sort based on the volunteers last name.

Use the volunteer.html file to add functionality to our form. This new functionality should allow the user to enter in volunteers to be added as well as delete volunteers from the list by re-entering in their name. The volunteer list should also be altered to use a looping structure to display a running count of volunteers beside each name (starting at 1) beside each name similar to the following display: 1. John Smith 2. Jane Willow 3. Randolph Jack 4. Jen Stevens Hint: Use the splice function in order to remove a specific item from the array. Tip: The array index starts at 0, so when displaying the index, you will need to add 1 to the index value when it is displayed. Make sure to do the following: Write JavaScript to delete a specific volunteer by using loop. Write JavaScript that loops through the volunteer list to display the index value. Once completed, view your pages in each of your two selected Web browsers to see if the content renders appropriately and consistently within each.

Here is my volunteer.js file and the volunteer.html file to referece:

var $ = function (id) { return document.getElementById(id); };

var volunteerArray = [];

var displayVolunteers = function () {

// display the volunteers in the text area

$("volunteerList").value = volunteerArray.join(" ");

// comment out the line above change this to a loop instead to loop through the array.

};

var addVolunteer = function () {

// get the data from the form

var volunteerString = $("first_name").value + " " + $("last_name").value;

// store the data in an array

volunteerArray.push(volunteerString);

// display the volunteers and clear the add form

displayVolunteers();

// get the add form ready for next entry

$("first_name").value = "";

$("last_name").value = "";

$("first_name").focus();

};

var deleteVolunteer = function () {

// get the data from the form (hint: use the same format as from the add).

// remove the string from the array (hint, loop through the entire list, compare the string with the item in the array.

// display the volunteers and clear the add form

displayVolunteers();

// get the delete form ready for next entry

$("first_name").value = "";

$("last_name").value = "";

$("first_name").focus();

};

var clearList = function () {

// delete the data from the arrays

volunteerArray = [];

// alternative way to delete all of the data from the array

// volunteerArray.length = 0;

// remove the volunteers data from the web page

$("volunteerList").value = "";

$("first_name").focus();

};

var sortList = function () {

// sort the scores

volunteerArray.sort();

// display the scores

displayVolunteers();

};

//When the page is fully loaded, the buttons will be mapped to the JavaScript functions

window.onload = function () {

$("add_button").onclick = addVolunteer;

$("delete_button").onclick = deleteVolunteer;

$("clear_button").onclick = clearList;

$("sort_button").onclick = sortList;

$("first_name").focus();

};

HTML

Invitation Page

CapellaVolunteers.org

Volunteers

Volunteer List

This events site is for IT3515 tasks.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions