Link to home
Start Free TrialLog in
Avatar of AtDev
AtDev

asked on

copy as you type from one field into another javascript

I'm looking for javascript that will dynamically copy one field that I am typing in into another field.

I have see other experts have come up with solutions but I can't seem to get it to work in firefox or ie6+
(https://www.experts-exchange.com/questions/21990368/Dynamic-Textboxes.html?sfQueryTermInfo=1+anoth+dynam+enter+field+javascript)
<html>
      <head>
            <script type="text/javascript">
                  var oldObj="";
                  function createNewText(obj){
                        if(document.getElementById(obj).value=="" && oldObj!=obj){
                              var nText=document.createElement('input');
                              nText.type="text";
                              nText.name="test"+(parseInt(obj.substring(4,obj.length))+1);
                              nText.id="test"+(parseInt(obj.substring(4,obj.length))+1);
                              nText.onkeypress=function(){createNewText(this.id);}
                              document.editentryform.appendChild(nText);
                              oldObj=obj;
                        }
                  }
            </script>
      </head>
<body topmargin="0" leftmargin="0">
      <form name="editentryform" method="post">
            <input type="text" value="" name="test1" id="test1" onkeypress="createNewText(this.id);">
      </form>
</body>
</html>

Open in new window

SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial