function addContent() {
var UserInput = document.getElementById("Input").value;
var UserOutput = document.getElementById("Listing");
UserOutput.innerHTML += "<li><p>"+UserInput+"</p></li>";
}
But the assignment is to accomplish the same method using the DOM, heres what I have
function addContent() {
var UserInput = document.getElementById("Input").value;
var UserOutput = document.getElementById("Output");
var p = document.createElement("P");
var t = document.createTextNode(UserInput);
p.appendChild(t);
document.getElementsByID("t").appendChild(p);
}
With the new method, is there no way to add a list in there so I can keep track?
Sometimes the console can give you some useful hints. ;-) There is no such function as document.getElementsById() since an ID is always (well, should be) unique.
function addContent() {
var UserInput = document.getElementById("Input").value;
var UserOutput = document.getElementById("Output");
var p = document.createElement("P");
var t = document.createTextNode(UserInput);
p.appendChild(t);
UserOutput.appendChild(p);
}
The first and last of the following commands are only needed once - the ones in the middle relace your current code to create a list instead of a series of paragraphs.
var ol = document.createElement("ol");
var li = document.createElement('li');
ol.appendChild(li);
var t = document.createTextNode(UserInput);
li.appendChild(t);
document.getElementByID("t").appendChild(ol);