Javascipt将textbox1的键入文本打印到textbox2 [英] Javascipt to print the typed text of textbox1 to textbox2

查看:79
本文介绍了Javascipt将textbox1的键入文本打印到textbox2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我需要javacript才能在用户在textbox1中输入文本时自动键入单词,它应该在textbox2中自动显示.谁能给我Javascript

Hi all i need javacript for typing the word automatically when user enter a text in textbox1 it should display automatically in textbox2. Can any one give me the Javascript

推荐答案

我得到了答案


I got the answer


<script type="text/javascript">
function sync()
{
  var n1 = document.getElementById('TextBox1');
  var n2 = document.getElementById('TextBox2');
  n2.value = n1.value;
}
            </script>


这里是您要寻找的

将此代码放在标题"部分.

Here is what you looking for

Put this code in Header section.

<script type="text/javascript">
       function myValue(t1) {
           document.getElementById("<%=t2.ClientID %>").value = t1.value;
       }
   </script>



将代码放入Body



Put the code in Body

<input id="t1" type="text" runat="server" onkeypress="javascript:myValue(this)" />
<input id="t2" type="text" name="name" runat="server" value="" />



希望对您有帮助.



I hope this helps you well.


这篇关于Javascipt将textbox1的键入文本打印到textbox2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆