I want to copy the contents of the value from the textbox 1 to the textbox 2 with the respective id of bayar and destination. I use a library for the currency format.
function copyValue() {
var n1 = document.getElementById('bayar').value;
var rupiahFormat = new Intl.NumberFormat('id-ID', {
style: 'currency',
currency: 'IDR',
}).format(n1);
console.log(rupiahFormat);
document.getElementById('destination').value = rupiahFormat;
}
<input type="number" name="bayar" id="bayar" class="form-control" onkeyup="copyValue()" />
<input type="number" name="destination" id="destination" class="form-control" />
>Solution :
norally you use the event for that like addEventListsener and use the event you need for that
I have show you a example and it work
let n1 = document.getElementById('bayar');
let n2 = document.getElementById('destination');
n1.addEventListener('input', function(e) {
e.preventDefault(); // Correction : c'est "e.preventDefault();" et non "e.prenvent.default"
n2.value = e.target.value; // Correction : c'est "e.target.value" pour obtenir la valeur de l'élément n1
console.log(n2.value);
});
<input type="number" name="bayar" id="bayar" class="form-control" />
<input type="number" name="destination" id="destination" class="form-control" />
I wish you a good day