I have a page on which I want users to be able to create web objects on the same page with the push of a button. For example, to create a new draggable textfield object, a user would click on this button:

<form action="#">
    <input type="button" name="btn" id="btn" value="Make a Textfield" onclick="textfield(this);" />
	</form>

I'm not sure if that part is correct.

Below is the code for the function I came up with. However, it doesn't produce a new textfield. (Note the draggable class makes the object draggable - this part works if I create the textfield object manually).

function newtextfield() {
  newElement.type = "button";
        newElement.id = "button";
        newElement.name = "button";
        newElement.class = "draggable";

}

var newtextfield = next();

What would the function be for the button to produce textfields?

Thanks!

Look into the createElement and appendChild functions of DOM to achieve your task.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.