Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

pls anyone help me to solve this problem,

i want to create dynamic controls in html/javascript.

i have div, inside that div i use radio, textarea, select, link. so when i click button i need to show div dynamically.

i search ready many sites,according that i need to use append command, but not clear way.

pls anyone help me :)

thanks
renga.
Posted
Comments
[no name] 15-Sep-14 22:33pm    
http://www.bing.com/search?q=create+dynamic+controls+in+html%2Fjavascript

1 solution

Hi try the below code,


HTML
<input type="button" value="Add" onclick="add()" />
<div id="divEl"></div>



JavaScript
function add() {
 
    //Create an input type dynamically.
    var element = document.createElement("input");
 
    //Assign different attributes to the element.
    element.setAttribute("type", "button");
    element.setAttribute("value", "text");
    element.setAttribute("name", "radio");
 
 
    var divEl= document.getElementById("divEl");
 
    //Append the element in page (in span).
    divEl.appendChild(element);
 
}




Hopes this will help for you......
 
Share this answer
 
Comments
Renga.g 19-Sep-14 0:16am    
hi thanks :) :) :)

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