Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

92
Vistas
How to convert a value from a range input field to currency format

I am trying to convert the output of the range from the input field to a Currency Format in Js. The Numbers are displaying correctly but I will like to convert it to Number Format on the output

const slider = document.getElementById("idc");
const value = document.getElementById("idk");
value.textContent = slider.value;
slider.oninput = function() {
  value.textContent = this.value;
}
<input type="range" name="range" min="0" max="5000000" id="idc" step="1000" value="0">
<h4>$</h4>
<h4 id="idk">0</h4>

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Does this work for you?

const slider = document.getElementById("idc");
const value = document.getElementById("idk");
value.textContent = slider.value;
slider.oninput = function() {
  value.textContent = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(this.value);
}
<input type="range" name="range" min="0" max="5000000" id="idc" step="1000" value="0">
<h4>$</h4>
<h4 id="idk">0</h4>

7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.