简体   繁体   English

自动复制文本框中的数据

[英]Auto copy data in Textbox

When loaded data in textbox and I want auto copy this data in textbox then will paste to another textbox.当在文本框中加载数据并且我想在文本框中自动复制此数据然后将粘贴到另一个文本框。 Below is my script, but it is not reach as my request.下面是我的脚本,但它没有达到我的要求。

var stringValue = document.getElementById("Price").value; 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('');
        };
        

    };

I think you want to copy entered data from the first element to next element on every keyUp events!我认为您想在每个 keyUp 事件中将输入的数据从第一个元素复制到下一个元素!

so this is the elements所以这是元素

<input type="text" id="Price" />
<input type="text" id="copy_Price"/>

and the correct script described in bellow以及下面描述的正确脚本

<script>   
    document.getElementById("Price").onkeyup = function ()
    {
        var stringValue = document.getElementById("Price").value;
        document.getElementById("copy_Price").value = stringValue;
    }
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM