Question: Assignment A3 This assignment involves you creating a solution to display shopping cart data for a company. You will be using variables, operators and functions.

Assignment A3 This assignment involves you creating a solution to display shopping cart data for a company. You will be using variables, operators and functions. Assignment Goal You have been asked to create a solution that will read data for an order that you will be given, and do the following with that data: 1. Display the item data within the correct areas of the given layout 2. Calculate the total for the item 3. Calculate the sales tax based on total item price 4. Calculate the grand total with item price and sales tax combined Assignment Requirements Your script must follow these requirements: 1. You can not alter the html file in any way as far as manually adding content to it. Everything you do will be based on JavaScript. 2. You must include the four function as described below. 3. You must use the techniques we covered in this tutorial. 4. You must comment all lines of code in your JavaScript file so I can read them and understand exactly what that command should do. Getting Started 1. Open up the index.html file as well as the orderform.js file that is within your orders folder. 2. Examine the code so you are familiar with what you are working with. Creating your setHTMLValues() function: 3. Within your orderform.js file, create a new function named setHTMLValues. a. This function should include two parameters: i. A field value you are going to pass in to the function ii. A field name you are going to pass in to the function b. This function should accomplish the following when it is called: i. Use the getElementById() method to target the field name that you passed in to this function, and use the textContent() method to set the value of that html element to the field value you passed in to this function. ii. That is all that you need to do within this function. Next you will be calling it. If you look at your index.html file, you will see that just below the body tag, there are four hidden input elements that we are going to use. Each input has a specific id associate with it, as well as a value. This is to simulate the item ordered for this example. 4. In order to use the function you just created, you need to do the following: a. Note: this is done outside of the function below the function. b. Create a new variable and name it item_name_value c. Use the getElementById() method to grab the value of this specific element - so the element with an id of item_name_value would have a value of Widget # 52415. Hint: never wonder if you created a variable correctly and assigned it a correct value. Instead, do something like print it to the screen, or even easier, add an alert so that when you run your html file, it pops up with an alert that would show you the value of that variable. So here we could test it by using: alert(item_name_value); If you run the page in the browser, it should come up and show you Widget # 52415 if not, you need to work on getting the correct value for that variable. d. Now that you have the variable, you need to call the setHTMLValues() function and pass in the needed parameters. i. The first parameter you pass in should be the variable you just created. ii. The second parameter should be the specific table cell that you want to display that data in. iii. So in this case, you would target the cell e. Save everything and run it in a browser. If you see the value show up in the first cell of the second row, then you are good to go. If you do not see that, then you need to troubleshoot your function call, or the statement within your function. 5. Assuming everything is working like it should be, do the following: a. Create a new variable for item_price_value and target the appropriate hidden input. b. Call the setHTMLValues() function and pass in the needed parameters. c. Create a new variable for item_quantity_value and target the appropriate hidden input. d. Call the setHTMLValues() function and pass in the needed parameters. e. When done, you should have the following showing on your page Create the calculateTotal() function: 6. Below the first function, create a second function and name it calculateTotal. a. This function should include two parameters (which you already have): i. The quantity (so the variable that holds that value) ii. The price b. This function should accomplish the following when it is called: i. Return the calculated total of quantity times price 7. Create a new variable named total that will call this function and pass in the correct parameters 8. Call the setHTMLValues() function to set the correct value inside the correct Create the calculateSalesTax() function: 9. Below the calculateTotal() function, create a third function and name it calculateSalesTax. a. This function should include two parameters (which you already have): i. The total (so the variable that holds that value) ii. The tax rate for this order b. This function should accomplish the following when it is called: i. Return the calculated tax of total times tax rate 10. Create a new variable named item_tax_rate_value that uses the GetElementById just like you did for the first three variables you created. 11. Create a new variable named taxTotal that will call this function and pass in the correct parameters 12. Call the setHTMLValues() function to set the correct value inside the correct Create the calculateGrandTotal() function: 13. Below the caluculateSalesTax() function, create a fourth function and name it calculateGrandTotal(). 14. This function should include two parameters: a. The total b. The taxTotal 15. Create a new variable named grandTotal that will call this function and pass in the correct parameters 16. Call the setHTMLValues() function to set the correct value inside the correct.

I need help staring with question 4, on parsing the string to integer and to display the values onto the table.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!