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

318
Visualizações
Input with type="radio". And span where i need to get a result by only clicking on "yes"

I'm learning JS. I created an input with type="radio". And there is span where i need to get a result by only clicking on "yes". What is wrong? Why doesn't it work? Could someone help me please?

    <h2>Do you need transportation?</h2>
    <div class="transport">
        <input class="radio" id="yesTransport" name="t" type="radio">
        <label for="yesTransport">Yes</label>
        
        <input class="radio" id="noTransport" name="t" type="radio" checked>
        <label for="noTransport">No</label>
    </div>
    
    <button id="calculate">РАССЧИТАТЬ</button>
    
    <div id="transportation">
        <span class="forWhat">За трансфер</span>
        <span>₽
          <span id="transportationTotal"></span>
        </span>
    </div>

code:

    const transpYes = document.querySelector("#yesTransport");
    transpYes.addEventListener("change", transpNeeded);
    
    function transpNeeded() {
        let amountUpTo3 = 50;
        let amountUpTo5 = 100;
        if (people == 1 || people <= 3) {
             document.querySelector("#transportationTotal").textContent = amountUpTo3.toFixed(2);
        }
        else if (people > 3 || people <= 5) {
            document.querySelector("#transportationTotal").textContent = amountUpTo5.toFixed(2);
        }

There is const people as well in another part of the code:

const people = document.querySelector("#people").value;
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