Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to duplicate value textboxt html with currency format?

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading