JavaScript Within the script section create two global variables: one named i with a value of , and the other named listItem with its value set to an empty string.. 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 . The ifstatement 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.. Before the closing } of the if statement, create a nested if statement. If the value of i is equal to , the statement should change the content of the element with the id of resultsExpl to the string “Thanks for your suggestions.”. Before the closing } of the main if statement, after the nested if statement, add a statement to increment the value of i by .. Add a backward-compatible event listener for the click event to the Submit button
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
JavaScript
Within the script section create two global variables: one named i with a value of , and the other named listItem with its value set to an empty string.. 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 . The ifstatement 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.. Before the closing } of the if statement, create a nested if statement. If the value of i is equal to , the statement should change the content of the element with the id of resultsExpl to the string “Thanks for your suggestions.”. Before the closing } of the main if statement, after the nested if statement, add a statement to increment the value of i by .. Add a backward-compatible event listener for the click event to the Submit button (with the id of button).. 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.
Here is the code I hve to start
My code for the solution
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>Hands-on Project 3-4</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 3-4 </h1> </header> <article> <div id="results"> <ul> <li id="item1"></li> <li id="item2"></li> <li id="item3"></li> <li id="item4"></li> <li id="item5"></li> </ul> <p id="resultsExpl"></p> </div> <form> <fieldset> <label for="toolBox" id="placeLabel"> Type the name of a tool, then click Submit: </label> <input type="text" id="toolBox" /> </fieldset> <fieldset> <button type="button" id="button">Submit</button> </fieldset> </form> </article> </body> </html>
Trending now
This is a popular solution!
Step by step
Solved in 2 steps