Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Creating dynamic textbox not working in IE

JavaScript
// Create a new text input
var newText = document.createElement('input');
newText.type = "input";
Posted
Updated 20-Nov-12 1:58am
v2
Comments
ZurdoDev 20-Nov-12 7:59am    
I haven't done it this way before but I believe you'll still have to add newText to the DOM.

The type of input should be text because you are creating a textbox here with this code.
Try this:
JavaScript
// Create a new text input
var newText = document.createElement('input');
newText.type = "text";
newText.name = "textbox1";
document.forms[0].appendChild(newText);



--Amit
 
Share this answer
 
v2
this code working well in IE, you may be block activeX control or script.. please check it while loading of page.. otherwise its working fine.

JavaScript
<script>
function myFunction()
{
var btn=document.createElement("input");
var t=document.createTextNode("CLICK ME");
btn.appendChild(t);
document.body.appendChild(btn);
};
</script>

HTML
<body>
<p id="demo">Click the button to make a BUTTON element with text.</p>
<button  önclick="myFunction()">Try it</button>
</body>
 
Share this answer
 
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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