Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q476 How can I get a text entered in one text field copied in realtime to another text field?

irt.org | Knowledge Base | JavaScript | Form 10.1 | Q476 [ previous next ]

Q476 How can I get a text entered in one text field copied in realtime to another text field?

This is only really possible in Netscape Navigator 4 and Internet Explorer 4 with the onKeyUp event handler:

<html>

<head>
<script language="JavaScript"><!--
function copyData(from,to) { to.value = from.value; }
//--></script>
</head>
<body>

<form name="myForm">
<input type="text" name="field1"
    onChange="copyData(this,document.myForm.field2)"
    onKeyUp="copyData(this,document.myForm.field2)">
<input type="text" name="field2"
    onChange="copyData(this,document.myForm.field1)"
    onKeyUp="copyData(this,document.myForm.field1)">
</form>

</body>
</html>

With any older browser you have to wait until the onChange event is triggered, when the user moves away from the text field.


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.