Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please help with this question? Thanks In this exercise, youll develop an application that tracks students scores, tallies the average of the entered

Can you please help with this question? Thanks

In this exercise, youll develop an application that tracks students scores, tallies

the average of the entered scores, and sorts the entered students by last name.

Open the HTML and JavaScript files in this folder:

exercises_extra\ch09\scores\

2. In the JavaScript file, note that six functions are supplied. The $ function.

The start of a displayScores function. The start of an addScore function that

ends by clearing the add form and setting the focus on its first field. The start

of a clearScores function that ends by clearing the display area and setting

the focus on the first name field. The start of a sortScores function. And an

onload event handler that attaches the addScore, clearScores, and sortScores

functions to the click events of the appropriate buttons and sets the focus on

the first name field.

3. To start, code two global arrays, one to hold the score values and the other to

hold the strings that display the students names and scores.

4. In the displayScores function, add the code that calculates the average score of all

the scores in the first array, and stores it in the text box below the text area. Then,

add the code that gets the students names and scores in the second array and

displays it in the text area.

5. In the addScore function, use the push method to save the score in the first array

and to save the name and score string (as shown in the text box) in the second

array. Then, call the displayScores function to redisplay the updated data.

6. In the clearScores function, add code that clears both global arrays.

7. In the sortScores function, add code that sorts the students by last name and then

re-displays the score information.

Here are the files:

html file:

Student Scores

Student Scores

Student Scores

.js file

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

var displayScores = function () { };

var addScore = function () { // get the add form ready for next entry $("first_name").value = ""; $("last_name").value = ""; $("score").value = ""; $("first_name").focus(); };

var clearScores = function () {

// remove the score data from the web page $("average_score").value = ""; $("scores").value = ""; $("first_name").focus(); };

var sortScores = function () { };

window.onload = function () { $("add_button").onclick = addScore; $("clear_button").onclick = clearScores; $("sort_button").onclick = sortScores; $("first_name").focus(); };

.css file

body { font-family: Arial, Helvetica, sans-serif; background-color: white; margin: 0 auto; width: 600px; border: 3px solid blue; padding: 10px 20px; } h1, h2 { color: blue; } h2 { border-bottom: 2px solid black; } label { float: left; width: 11em; text-align: right; padding-bottom: .5em; } input { margin-left: 1em; margin-bottom: .5em; }

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

Step: 3

blur-text-image

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

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

Explain the importance of Human Resource Management

Answered: 1 week ago

Question

Discuss the scope of Human Resource Management

Answered: 1 week ago