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

191
Visualizações
Show Hidden Text Box when two radio boxes AND button are clicked

Here is the HTML code of the two radio buttons and button

<body>


    <input data-image="small" type="radio" id="small" name="size" value="20" class="radios1"> 
    <label for="small"><span></span></label> 
    <div class="label">Small</div>    

    <input data-image="green" data-image1="small_green" type="radio" id="green" name="color" value="0" class="radios2" > 
    <label for="green"><span></span></label> 
    <div class="label">Green</div>    

    <button type="button" class="cart-btn" id="cartbutton" name="cart" value="5">Add To Cart!</button>
</body>

Here is the script I have so far. I got it to work with just the radio buttons but when I added the button script it stopped working.

<script>

const sizeSelector = 'input:radio[name=size]';
const colorSelector = 'input:radio[name=color]';
const cartSelector = 'input:button[name=cart]';

$(function () {
  
  // We can add the click event to all radio buttons by linking
  // their selectors with commans.
  $(`${sizeSelector}, ${colorSelector}, ${cartSelector}`).click(() => {    
    toggleWhenSmallAndGreenAndCartButton();
  });
  
});

const SMALL = 20;
const GREEN = 0;
const CARTBUTTON = 5;
function toggleWhenSmallAndGreenAndCartButton(){  
  let size = $(`${sizeSelector}:checked`).val();
  let color = $(`${colorSelector}:checked`).val();
  let cart = $(`${cartSelector}:selected`).val();
  $('#itemdv').toggle(size == SMALL && color == GREEN && cart == CARTBUTTON) && $('#itemdv2').toggle(size == SMALL && color == GREEN && cart == CARTBUTTON);
}


</script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

your button selector is wrong it is not a input type. change it to 'button[name=cart]'

about 4 years ago · Juan Pablo Isaza Relatório
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