Click here to Skip to main content
15,885,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created button to dynamically creating textbox

HTML
<INPUT type="button" name="element1" value="text"  önclick="add(document.forms[0].element1.value)" style="width: 57px"/>


JavaScript
<script language="javascript"/>
function add(type) {
 
    //Create an input type dynamically.
    var element = document.createElement("input");
 
    //Assign different attributes to the element.
    element.setAttribute("type", type);
    element.setAttribute("value", type);
    element.setAttribute("name", type);   
}


Now how can i add this to div tag?????????????????????????? Need ur help
Posted
Updated 16-Jun-12 20:09pm
v2

1 solution

Now how can i add this to div tag?
Try something like this:
JavaScript
var divTOAdd = document.getElementById("myDivName");
divTOAdd.appendChild(myElement);
 
Share this answer
 
Comments
gdhhdjdjuhd 17-Jun-12 7:36am    
Thanks! I thnk i got my answer...:)
Sandeep Mewara 17-Jun-12 7:58am    
Welcome.
gdhhdjdjuhd 17-Jun-12 22:50pm    
bro now i attached a text editor to div like this

<div style="clear: both;"></div><script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script> <script type="text/javascript">
//<![CDATA[
var area1;

function toggleArea1() {
if(!area1) {
area1 = new nicEditor({fullPanel : true}).panelInstance('myArea1',{hasPanel : true});

}
}



bkLib.onDomLoaded(function() { toggleArea1();

});
//]]>
</script>
</div>
Now i am not able to add tht last textbox into this div.. do u have any solution??
gdhhdjdjuhd 17-Jun-12 22:52pm    
myArea1 is div name...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900