Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy textbox value into another textbox 1

Status
Not open for further replies.

aspdotnetuser

Programmer
Oct 10, 2008
45
GB
Hi,

I'm new to using Javascript and I'm trying make a function to copy text from one textbox into another when the user clicks a button, I'm using the javascript at the top of .aspx page. Here is the code for the javascript but it doesn't seem to work:

[blue]function button1()
{
var text1value = document.getElementById("text1").value;
var text2value = document.getElementById("text2").value;

document.getElementById("TextBox1").value = text1value;
document.getElementById("TextBox2").value = text2value;
}[/blue]
 
Hi

That should work, supposing the [tt]id[/tt]s in your HTML are used accordingly.

Post the HTML source code [green](*)[/green] too ( if is huge, at least the [tt]form[/tt] ) or give us an URL to a publicly accessible copy of the page.

[green](*)[/green] - As it is displayed by your browser's View page source command.

Feherke.
 
Thanks for your reply feherke. I managed to fix this code, I think it was because the html button didn't have an ID attribute.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top