Copying text boxes data?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

Copying text boxes data?

Post 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.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post 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 :)
Post Reply