我有两个相互镜像的文本框。每当用户输入到文本框 1 时,将自动复制到文本框 2。但是是否可以将其复制到文本框 2 并使用单引号,并且在放置逗号时,另一个值将用单引号关闭。
例如:用户输入(textbox1):苹果
文本框 2(复制值):'apple'
用户输入(textbox1):苹果,橙色
文本框 2(复制值):'apple','orange'
我什至不确定这是否可能,但每一个帮助都将不胜感激。到目前为止,这就是我复制文本框值的方法
function sync()
{
var n1 = document.getElementById('sample1');
var n2 = document.getElementById('sample2');
n2.value = n1.value;
}
Input 1: <input type="text" style= "width: 230px; padding-left: 3px" id="sample1" name="sample1" onkeyup="sync()">
<br>
Copied Input: <input type="text" style= "width: 230px; padding-left: 3px" id="sample2" name="sample2">