问题描述
在文本框中加载数据后,我想自动在文本框中复制此数据,然后将其粘贴到另一个文本框中。下面是我的脚本,但未达到我的要求。
var stringValue = document.getElementById(“ Price”)。value;
document.getElementById("Price").onkeyup = function ()
{
window.onload = function () {
document.getElementById("copy_Price").value = stringValue + this.value.split('').reverse().join('').replace(/\d\d\d(?!$)/g,"$&,").split('').reverse().join('');
};
};
解决方法
我认为您想在每个keyUp事件中将输入的数据从第一个元素复制到下一个元素!
这就是元素
<input type="text" id="Price" />
<input type="text" id="copy_Price"/>
以及下面介绍的正确脚本
<script>
document.getElementById("Price").onkeyup = function ()
{
var stringValue = document.getElementById("Price").value;
document.getElementById("copy_Price").value = stringValue;
}
</script>