Hulk Hulk - 1 year ago 86
HTML Question

Copy contents of one textbox to another

Suppose an entry is made in a textbox. Is it possible to retain the same entered text in a second text box? If so, how is this done?

<label>First</label><input type="text" name="n1" id="n1">
<label>Second</label><input type="text" name="n1" id="n1"/>


Answer Source
function sync()
  var n1 = document.getElementById('n1');
  var n2 = document.getElementById('n2');
  n2.value = n1.value;
<input type="text" name="n1" id="n1" onkeyup="sync()">
<input type="text" name="n2" id="n2"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download