Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i click add button,t want to create new text field.
Posted

i click add button want to create new text field.
Javascript

1. Define client side button click event
2. In the button click event, create an input element
3. define the properties like id, width, type etc of the input element
4. Add the input element to a defined div/placeholder

A new text field will be created and shown in the given location. Try!
 
Share this answer
 
see this script
Dynamically textbox
 
Share this answer
 
Try this,


HTML
<div id="div2"></div> 

<input type="button" id="btnok" onclick="addText();" value="text" />
        <br /> 


JavaScript
<script type="text/javascript">
function addText()
        {
        var div1=document.getElementById("div2");
        div1.innerHTML="<input type='text'/>";
        }
 </script>
 
Share this answer
 
try below code:
Method1:
call at button click event server side:

lblCessCategory.Text = CessDetail + " ";
lblCessCategory.Text = lblCessCategory.Text + ds.Tables[0].Rows[i]["CessCategoryName"].ToString();

lblCessCategory.Text = lblCessCategory.Text + "
";
lblCessCategory.Text = lblCessCategory.Text + "<input type='button' id='btnID'>";

lblCessCategory.Text = lblCessCategory.Text + "";

lblCessCategory.Text = lblCessCategory.Text + "<input type='text' id='txtID'>";
lblCessCategory.Text = lblCessCategory.Text + " ";


put one label at .aspx page. Label id will be lblCessCategory .

Method2:

You can call javascript function for doing this as told in last solution by shobhna.
 
Share this answer
 

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