Page 1 of 1

Copying text boxes data?

Posted: Mon Oct 23, 2006 7:59 pm
by cturner
I am wanting to display data that is in some text boxes into other text boxes that is on one page after a check box has been selected. Can someone please tell me how I can do this with some code. Thanks in advance.

Posted: Mon Oct 23, 2006 8:07 pm
by alex.barylski
Javascript.

Code: Select all

<form name="test">
<input type="text" id="field_1" name="field_1" />
<input type="text" id="field_2" name="field_2" />
<input type="checkbox" onclick="copyContent" />
</form>

Code: Select all

function copyContent()
{
  //var tmp = document.forms.test.field_1.value - If below doesn't work?
  var tmp = document.getElementById('field_1').value;
  document.getElementById('field_2').value = tmp;
}
Untested but you get the idea :)

Cheers :)