Forums » .NET » ASP.NET »

Javascript::How to create text box dynamically


Posted Date: 08 Dec 2005      Posted By:: deepak pal     Member Level: Silver  Member Rank: 0     Points: 2   Responses: 2

how to create text box dynamically on button's click event plz give my code in javascript not in .aspx

Responses

#36125    Author: Pankaj Mishra      Member Level: Gold      Member Rank: 0     Date: 08/Dec/2005   Rating: 2 out of 52 out of 5     Points: 2

HI
Use this code for creating textBox using javascript dynamically


function createTXTBox()
{
var loContentTable = document.getElementById("tblCreateTextBox"); //"tblCreateTextBox" Table id
if(loContentTable != null)
{

for(var count=0; count < 200 ;count++)
{
var loTR = loContentTable.insertRow(loContentTable.rows.length);
if(loTR != null)
{
var loTXTBox=loTR.insertCell(0);
if(loTXTBox!=null)
{
var contentPlace = document.getElementById("contentPlace");//contentPlace is td in the table "tblCreateTextBox"

var text12 = document.createTextNode("Auto");
var input12 = document.createElement("Input");
input12.value="auto";

input12.type="text";
loTXTBox.width="15px";

loTXTBox!.innerHTML = "<input type='text' id='count' value=tempCount onclick='javascript:doSomeThing(this)'>"

}
}
}
}
}


Pankaj

Regards,
Pankaj


 
#290321    Author: Ultimaterengan      Member Level: Gold      Member Rank: 0     Date: 02/Sep/2008   Rating: 2 out of 52 out of 5     Points: 2

<html>
<head>
<title>Dynamic Form</title>
<script type="text/javascript" >
function CreateTextbox()
{
var i = 1;
createTextbox.innerHTML = createTextbox.innerHTML +"<input type=text name='mytext'+ i/>"

}
</script>
</head>
<body>

<form name="form" action="post" method="">
<input type="button" value="clickHere" onClick="CreateTextbox()">
<div id="createTextbox"></div>
</form>
</body>



Thanks & Regards
G.Renganathan
Nothing is mine ,Everything is yours!!!



 
Post Reply     

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.





  • Return to Discussion Forum
  • Start new thread


  • Top Contributors
    Today
      Last 7 Days
        more...

        Awards & Gifts

        Online Members

        More...
         
        Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India