将一个文本框的内容复制到另一个 [英] Copy contents of one textbox to another
本文介绍了将一个文本框的内容复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< html>
< label>第一个< / label>< input type =textname =n1id =n1>
< label> Second< / label>< input type =textname =n1id =n1/>
< / html>
谢谢。
解决方案
<脚本>
函数sync()
{
var n1 = document.getElementById('n1');
var n2 = document.getElementById('n2');
n2.value = n1.value;
}
< / script>
< input type =textname =n1id =n1onkeyup =sync()>
< input type =textname =n2id =n2/>
Suppose an entry is made in a textbox. Is it possible to retain the same entered text in a second text box? If so, how is this done?
<html>
<label>First</label><input type="text" name="n1" id="n1">
<label>Second</label><input type="text" name="n1" id="n1"/>
</html>
Thanks.
解决方案
<script>
function sync()
{
var n1 = document.getElementById('n1');
var n2 = document.getElementById('n2');
n2.value = n1.value;
}
</script>
<input type="text" name="n1" id="n1" onkeyup="sync()">
<input type="text" name="n2" id="n2"/>
这篇关于将一个文本框的内容复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文