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

223
Visualizações
button to be visible after it fulfilled requirements

Requirements: When more than one button is clicked, users will then be able to click on "proceed-button".

Current situation: I am making a cinema web page. Users will get to choose their preferred seats. When the seat is chosen, they will then be able to click on "proceed-button" to pay. However, i have difficulty implementing this function. I know that i needed to use the visibility-hidden function.

The following is my code:

var buttons = document.getElementsByClassName("button");
var count = 0;
var disp = document.getElementById("display");
for (let i = 0, l = buttons.length; i < l; i++) {
  buttons[i].addEventListener('click', function() {
    buttons[i].classList.toggle('active');
    if (this.classList.contains("active")) {
      count++;
      if (this.classList.contains("active") > 1) {
        function proceedButton() {
          document.getElementById("pButton").style.display = "visible";
        }
      } else {
        document.getElementById("pButton").style.display = "block";
      }

    } else {
      count--;
    }
    disp.innerHTML = count;
  })
}

function proceedButton() {
  var x = document.getElementById("payment-section");
  if (x.style.display === "none") {
    x.style.display = "block";
  }
}
.button {
  background-color: #423F3E;
  height: 30px;
  width: 30px;
  margin: 5px;
  border-radius: 10px;
  border: none;
  float: left;
}

.button.active {
  background-color: #F7EA00 !important;
}
<div class="seats-layout">
  <div class="row">
    <input type="button" id="button1" class="button" />
    <input type="button" id="button2" class="button" />
    <input type="button" id="button3" class="button" />
  </div>
  <div class="row">
    <input type="button" id="button1" class="button" />
    <input type="button" id="button2" class="button" />
    <input type="button" id="button3" class="button" />
  </div>
</div>
<p> Button Clicked <span id="display">0</span> Times</p>
<input type="submit" value="Proceed" onclick="proceedButton()" id="pButton" class="proceed-button" />
```
<div id="payment-section" style="display: none">
<h1>Payment</h1>
</div>
```

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Demo page

use document.querySelectorAll to returns all elements in the document that matches a specified CSS selector(s), as a static NodeList object.

function proceedButton() {
  var x = document.getElementById("payment-section");
  var item_click = document.querySelectorAll('.active').length;
  if (item_click>1) {
    x.style.display = "block";
  }else{
    x.style.display = "none";
  }
}
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