Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    create textbon on button click

    hai,

    When i click on a button once, a textbox should be created.
    I click again, another textbox should be created.

    how to do this

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    welcome to the Forum

    Try this DOM example:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script language="JavaScript" type="text/JavaScript">
    var 
    k=1;
    function 
    newT(){
    var 
    oName ='mytextbox'+k;//here's the name of the first texbox: mytextbox1
    //The folowing will be incremented as mytextbox2, mytextbox3, mytextbox4 and so on
    var root document.getElementById('cont');
    var 
    oInp document.createElement('input');
    var 
    oBr document.createElement('br');
    oInp.setAttribute('type','text');
    oInp.setAttribute('name',oName);
    root.appendChild(oInp);
    root.appendChild(oBr);
    k++;
    }
    </script>
    </head>
    <body>
    <input type="button" value="Create new textbox" onclick="newT()"><br>
    <br>
    <div id="cont"></div>
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •