Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
cuando edito span, el filtro de rango se actualiza solo

Solo estoy tratando de hacer que el filtro de rango se pueda cambiar no arrastrando el filtro, sino escribiendo el valor. El valor se actualiza automáticamente en console.log, pero visualmente no se queda en un solo lugar (y luego tengo un problema para tomar el valor por el método $_POST.

 <input id="range_filter" class="range-slider__range sum" type="range" value="10000" min="5000" max="100000" oninput="editor.value = range_filter.value"> <span contenteditable="true" id="editor" class="range-slider__value">0</span>
 function edit() { //console.log("input event fired"); var val1 = document.getElementById("range_filter").value; document.getElementById('editor').value = document.getElementById('editor').innerHTML; var val2 = document.getElementById("editor").value; val1 = val2; console.log(val1); console.log(val2); } var el = document.getElementById("editor"); if(el) { el.addEventListener('input', edit, false); }

https://jsfiddle.net/d63sgacn/12/

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Cuando establece val en document.getElementById(...).value , entonces val ya no es una referencia al valor del elemento, es solo un número almacenado en una variable, lo mismo que si hubiera escrito let x = 5 .

En lugar de extraer el valor, simplemente mantenga las referencias a los elementos.

 function edit() { const slider = document.getElementById("range_filter"); const numberInput = document.getElementById("editor"); slider.value = numberInput.value; } var el = document.getElementById("editor"); if (el) { el.addEventListener('input', edit, false); }

Además, no hay motivo para que la entrada sea un <span> . Eso no limita la entrada del usuario solo a números. Simplemente conviértalo en un <input type="number"> estándar.

 <input id="range_filter" class="range-slider__range sum" type="range" value="10000" min="5000" max="100000" oninput="editor.value = range_filter.value"> <input type="number" id="editor" class="range-slider__value" value="0" />
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!