Click here to Skip to main content
14,301,046 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have created button to dynamically creating textbox

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


<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

Rate this:
Please Sign up or sign in to vote.

Solution 1

Now how can i add this to div tag?
Try something like this:
var divTOAdd = document.getElementById("myDivName");
divTOAdd.appendChild(myElement);
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100