Answer to Question #47452 in AJAX | JavaScript | HTML | PHP for John

Question #47452
I need a JS Code to Work with the following HTML Code:
<!DOCTYPE html>
<html>
<head>
<title>Shopping List</title>
<script type="text/javascript" src=""></script>
</head>
<body>
<p>Use the field below to add items to your shopping list.</p>
<input type="text" name="txtItem" id="txtItem" placeholder="Enter an Item" />
<br />
<br />

<button onclick="AddItem();">Add Item</button>
<button onclick="RemoveLastItem();">Remove Last Item</button>
<div id="printedList"></div>
</body>
</html>

I came up with this:
var shoppingList = ['Milk', 'Eggs', 'Bread'];
var outputDIV = document.getElementById('printedList');

function AddItem(){
shoppingList.push('Bananas');
document.getElementById('printedList').innerHTML = shoppingList;
}
function RemoveLastItem(){
shoppingList.pop();
document.getElementById('printedList').innerHTML = shoppingList;
}

I need to to have it to involve this:

shoppingList.push('item to add');

shoppingList.pop();

and lastly the ouputDIV

outputDIV.innerHTML = shoppingList.toString();
1
Expert's answer
2014-10-02T14:01:01-0400
The answer to the question is available in the PDF file https://www.assignmentexpert.com/homework-answers/programming-answer-47452.pdf

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS