Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

224
Vistas
how to change a button value on changing a slider value

briefly, we want to change a button value using a slider value change. the project is about a button and a slider with that conditions: 1- when there's a value of "0" with slider and the button value is "start" on clicking the button the slider value gets into 50% and the button value is "stop" and color "red". 2- when we change the slider value manually the button gets into red and value is stop 3- when there's a value for slider and clicking on the button with value stop it returns into green and value is start

js code:

function updateButton(btn) {
    
    var strt_chng = document.getElementById("chng_btn");
    var respn = document.getElementById("slider1");

      
    if (strt_chng.value == "Stsrt" || respn.value == 0) {
        strt_chng.value = "Stop";
        strt_chng.style.background = "red";
        respn.value = "50";
    }


    else if (strt_chng.value == "Start" || respn.value > 0) {
        strt_chng.value = "Stop";
        strt_chng.style.background = "red";
    }


    else {
        strt_chng.value = "Start";
        strt_chng.style.background = "green";
        respn.value = "0";

    }
}

html code:

<div class="speed-content">
        <div class="speed-slider">

            <input type="range" onchange="updateSliderPWM(this)" id="slider1" min="0" max="100" step="1" value="0" class="slider">
            <p class="state">Speed: <span id="sliderValue1"></span> &percnt;</p>

           [enter image description here][1]

        </div>

        <div class="speed-buttons">

            <input type="button" onclick="updateButton(this)" id="forward" class="button" value="Forward" />

            <input type="button" onclick="updateButton(this)" id="chng_btn" class="button" value="Start" />

            <input type="button" onclick="updateButton(this)" id="backward" class="button" value="Backward" />

        </div>
    </div>

can anyone help?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda