Results 1 to 3 of 3

Thread: New text box addition w/ input of previous text box

  1. #1
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default New text box addition w/ input of previous text box

    Hello, I'm looking for a solution for when the user starts typing in a text box and then an empty text box appears under it.

    I have found solutions to add a new row when user hits a "add new row" button but I am wanting a cleaner appearance with no button in place -- and the new/empty text box automatically appears on input.

    The new text box addition would happen whenever user enters text in a text box and there would always be an empty row after all fields are entered.

    An example of what need is similar to http://bit.ly/mXDwu but with no ADD button in place and only text box additions (no buttons)

    Can anyone help me here? Thanks!
    Last edited by jaw; 04-23-2012 at 08:09 PM. Reason: reference

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function Add(ip){
     var frm=ip.form,nme=ip.name,nu=nme.replace(/\D/g,''),nme=nme.replace(/\d/g,''),nip;
     if (nu&&isFinite(nu*1)&&!frm[nme+(nu*1+1)]){
      nip=zxcAddField('INPUT','text',nme+(nu*1+1));
      nip.size=ip.size;
      ip.parentNode.appendChild(nip);
      nip.onclick=function(){ Add(this); }
     }
    }
    
    function zxcAddField(nn,type,nme){
     var obj;
     try {
      obj=document.createElement('<'+nn+' name="'+(nme||'')+'" '+(type?'type="'+type+'" ':'')+' >');
     }
     catch(error){
      obj=document.createElement(nn);
      if (type){
       obj.type=type;
      }
      obj.name=nme||'';
     }
     return obj;
    }
    
    /*]]>*/
    </script></head>
    
    <body>
    <form>
     <input name="tom1" size="10" onmouseup="Add(this);"/>
    </form>
    
    
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    jaw (04-24-2012)

  4. #3
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile

    Brillance, vwphillips! Thanks!

Bookmarks

Posting Permissions

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