How to add forms dynamically in javascript? Example speaks for it self:

function writeSpecialTabContentForTtm(){
        document.write('&lt;div style="float:right;width:250px;min-height:200px;display:block;border-width: 1px 1px 1px"&gt;');
        document.write('&lt;form  id="ttmsetpointrun" action="" style="text-align:right"&gt;');
        document.write('&lt;input style="float:bottom;" type="submit" value="Move to Set Point" /&gt;');
        document.write('&lt;/form&gt;');
        document.write('&lt;/div&gt;');


How this should be done? There is a form that is chosen by user. To be precise, user choses a tab and when creating a tab the above function is called. This is something that is changed frequently, so it would be nice to write it in a separate file.

edit:

so, in my case it would be:

var newdiv = document.createElement('div');
newdiv.style = "float:right;width:250px;min-height:200px;display:block;border-width: 1px 1px 1px";
document.body.appendChild(newdiv);  

var newform = document.createElement('form');
newform.id = "ttmsetpointrun"; 
newform.action="";
newform.style="text-align:right";
newdiv.appendChild(newform);

var newinput = document.createElement('input');
newinput.style = "float:bottom;";
newinput.type = "submit";
newinput.value = "Move to Set Point";
newform.appendChild(newinput);
To create dynamic forms and elements in javascript is easy.

var newdiv = document.createElement('div'); // Creates the div
document.body.appendChild(newdiv);          // Adds the div to body


After that, you can access newdiv and change attributes of it, such as 

newdiv.className = "helloworld";