I found this JavaScript online that adds input buttons when you press a button.
I changed it so that instead of being able to select which type of input you create it just automatically creates a textbox. But it's not working. What should I change?
function add(type) {
//Create an input type dynamically.
var element = document.createElement("input");
//Assign different attributes to the element.
element.setAttribute("type", "text");
element.setAttribute("name", "goal[]");
var foo = document.getElementById("fooBar");
//Append the element in page (in span).
foo.appendChild(element);
}
<INPUT type="button" value="Add" onclick="add(document.forms[0].element.value)"/>
<span id="fooBar"> </span>