MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / addItem

Function addItem

assets/js/KnapsackProblem.js:4–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2let totalProfit = 0;
3
4function addItem(){
5 count = count + 1;
6 let container = document.getElementById("itemInformations");
7 container.appendChild(document.createTextNode("Item " + count + " "));
8 // Create an <input> element, set its type and name attributes
9 let input = document.createElement("input");
10 input.type = "number";
11 input.name = "item" + count;
12 input.id = "item" + count;
13 input.class = "item";
14 input.placeholder = "Enter Weight (KG)"
15
16 container.appendChild(input);
17
18 container.appendChild(document.createTextNode(" Profit " + count + " "));
19 // Create an <input> element, set its type and name attributes
20 let input2 = document.createElement("input");
21 input2.type = "number";
22 input2.name = "profit" + count;
23 input2.id = "profit" + count;
24 input.class = "item";
25 input2.placeholder = "Enter Profit";
26
27 container.appendChild(input2);
28
29 // Append a line break
30 container.appendChild(document.createElement("br"));
31}
32
33function deleteItem(){
34

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected