Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JavaScript help. In this exercise, you will create a program that writes user input from a text box to a list on the web page.

JavaScript help.

In this exercise, you will create a program that writes user input from a text box to a list on the web page. Your program will also write a thank-you message to the page after the user has entered five items. Finally, youll also create a backward-compatible event listener for the Submit button.

1-At the bottom of the document, before the closing tag, create a new script section.

2-Within the script section create two global variables: one named i with a value of 1, and the other named listItem with its value set to an empty string.

3-Below the variables, create a function called processInput(). Within the function, create an if statement that runs if the value of i is less than or equal to 5. The if statement should perform the following actions:

a- Set the value of the listItem variable to the string item concatenated with the value of i.

b- Set the content of the element with an id equal to listItem to the value of the element with the id of toolbox.

c- Set the value of the element with the id of toolbox to an empty string.

4-Before the closing } of the if statement, create a nested if statement. If the value of i is equal to 5, the statement should change the content of the element with the id of resultsExpl to the string Thanks for your suggestions.

5-Before the closing } of the main if statement, after the nested if statement, add a statement to increment the value of i by 1.

6-Add a backward-compatible event listener for the click event to the Submit button (with the id of button).

7-Add comments to document your work, and then save your work. Open index.htm in a browser, type the name of a tool in the text box, and then click Submit. The name of the tool you typed is added to the bulleted list on the right side of the web page. Enter the names of four more tools, clicking Submit after each one. After you enter the fifth name, the text Thanks for your suggestions. is displayed below the bulleted list

8-Fix any errors in your code until it works as you expect.

Hands-on Project 3-4

Hands-on Project 3-4

Type the name of a tool, then click Submit:

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions