Question: javascript: Parallel Arrays: Create a Webpage to accept inventory item names and their costs for the inventory purpose. The user will enter the item and

javascript:

Parallel Arrays: Create a Webpage to accept inventory item names and their costs for the inventory purpose. The user will enter the item and its cost. By pressing the Add Item button the merchandise is added to the inventory. At any time the user can press the Display List button to see the complete list of items and their prices in an alert box. After adding more items, if you press this button again, you will see more items. Do not remove the previous items. Requirements: Create a form, table, and controls in your HTML file. Create two parallel arrays one for the names of the items, and one for the cost. Create a function called addItem( ). When the user clicks the Add Item button this function will retrieve the values from the screen and places them in the arrays. Do error checking. If the Name textbox is empty or the cost is not a numeric value, do not accept the values. Prompt the user if the entries are invalid. Make sure you will not add any values to the arrays in this case. Create another function to display the complete inventory. Add the usual comments. As you code, add more comments. Test, test, and test as you code. Debug your program in smart parts. Do not wait until the last moment. You will get frustrated when you encounter tons of errors. How to do it: Create two empty global arrays without specifying the size. If the values entered by the user are valid, use the push( ) method to add elements to the arrays. Please check your previous assignments for error checking codes. Use Array.length property in a for loop to display the values in the array elements. Your program output should look similar to this. 2 Hint: Size and the index numbers for both arrays should always be the same. Create a long string, then use alert() to display the items. Use in the string for new line.

this is my code im almost done just need some help

var itemName = new Array();

var cost = new Array();

var arrayCounter = 0;

//this function is used to take user input , it also holds the calculations for monthly rate and monthly payment

function addItem()

{

var userItemName = frmItemInventory.txtItemName.value;

var userItemCost = parseFloat(frmItemInventory.txtItemCost.value);

if(userItemName == " " && isNaN(userItemCost))

alert("do not leave blank, item will not be added .")

else if (userItemName == " " || isNaN(userItemCost))

alert("both fields have to be filled, nothing will be added.")

else

{

itemName.push(testItemName);

itemCost.push(testItemName);

arrayCounter++;

alert("item" + arrayCounter+ "added");

}

}

//this function displays the total monthly payment

function DisplayList()

{

var inventoryItems = "inventory Items: " ;

if(itemName[0] == undefined);

alert(inventoryItems +"no items in the inventory!");

else

}

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 Databases Questions!