Hulk Hulk - 7 months ago 25
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"/>


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"/>