Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!