In Javascript, you would create an input as follows.
var input = document.createElement('input');
input.type = 'button';
...
So, if you would like to create inputs on the fly, you could create a dropdown that lists the types of inputs as strings (button, text, etc.). Then, once the user had chosen the string in the dropdown, you would pass it to a Javascript function like the following:
function createInput(type) {
var input = document.createElement('input');
input.type = type
...
return input;
}
Then, if you wanted to append the input to an element on the page with id 'foo':
var input = createInput('button');
var appendToThis = document.getElementById('foo');
appendToThis.appendChild(input);
If you would like to start with a div on the page, imagine you have a div tag with id foo on the page:
<div id=foo><input type=text></div>
Then, when the user chooses an item, clear the div and make a new input:
function whenUserChoosesAType(type) {
var div = document.getElementById('foo');
rac(div);
var input = document.createElement('input');
div.appendChild(input);
}
//abbreviated function to clear the contents of a DOM element such as a div
function rac(elem) {
while(elem.hasChildNodes()) elem.removeChild(elem.firstChild);
}