How can I copy the content of a textbox to another textbox using javascript?
3 answers
Ol 'since you added the "beginner" tag:
<input type="text" id="t1" onkeyup="document.getElementById('t2').value = this.value" />
<input type="text" id="t2" />
A more robust solution also uses an event change
(for those who insert with the right mouse button) and does not inline the event handler logic:
<input type="text" id="t1" />
<input type="text" id="t2" />
<script>
var t1 = document.getElementById('t1');
t1.onkeyup = t1.onchange = function() {
document.getElementById('t2').value = this.value;
};
</script>
+6
source to share