Posted: 10/10/2011
Hi,I have two textboxes on my page say textbox1 and textbox2. Now I want to set the value of textbox2 with the value of textbox1 on button's click. Can you help me do that?
Posted: 10/11/2011
Hi,
You can use jquery to set value of a textbox into another text box
<input type="text" id="textBox1"/> <input type="text" id="textBox2"/> <input type="submit" id="btnclick"/>
$('#btnclick').click(function (e) { var textBox1 = $('#textBox1'); var textBox2 = $('#textBox2'); textBox2.val(textBox1.val()); });
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Title</title> </head> <body> <form id="HtmlForm" runat="server"> <input type="text" id="txt1" /> <input type="text" id="txt2" /> <input type="button" id="btnTest" onclick="foo()" value="Test"/> </form> <script type="text/javascript"> var foo = function () { document.getElementById("txt2").value = document.getElementById("txt1").value } </script> </body> </html>