troubleshooting Question

copy as you type from one field into another javascript

Avatar of AtDev
AtDev asked on
JavaScript
2 Comments2 Solutions1116 ViewsLast Modified:
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/Programming/Languages/Scripting/JavaScript/Q_21990368.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>
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros