JS - 动态更改文本字段 [英] JS - Dynamically change Textfield
本文介绍了JS - 动态更改文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从另一个文本框的值更改一个文本框中的值,而不进行任何提交。示例:
I'm trying to change the value in one textfield from the value of another textfield without any submits. Example:
[Textfield 1(输入'hello')]
[Textfield 1 (type 'hello')]
[Textfield 2('hello'is插入这里)]
[Textfield 2 ('hello' is inserted here as well)]
以下是我的表单:
<form action="#" id="form_field">
<input type="text" id="textfield1" value="">
<input type="text" id="textfield2" value="">
</form>
我不太了解JavaScript,这甚至是可能的吗?感谢任何帮助。
I don't know much about JavaScript, is this even possible? Would appreciate any help.
谢谢
推荐答案
<form action="#" id="form_field">
<input type="text" id="textfield1" value="" onKeyUp="document.getElementById('textfield2').value=this.value">
<input type="text" id="textfield2" value="">
</form>
看到它在行动中:
http://jsfiddle.net/4PAKE/
这篇关于JS - 动态更改文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文