Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda