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

193
Views
How to link two buttons in html

I have an HTML file that has two sections. One section has a form inside of it. And the other one has a message. If the user submits the form, then a message shows up and there will be another button the user has to press in order to complete the submission.

Is there any way to link a button so that the user has to press the other button in order to complete the original button job?

<section>
  <form>
    <input>...
    <button> 
        // User presses the first submit button
      </button>
  </form>
</section>
<div>
  <button>
     // User has to press this button next inorder to complete the form
   </button>
  <div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const form = document.querySelector("form"); // First grab the form
const btn2 = document.getElementById("button2"); // Second button, make sure to add the id or any other proper selector

let isSubmitted = false;

// Once form will be submitted from inside
// we will prevent the default behaviour of it so it does not do anything other than
// marking isSubmitted as true, so this can be checked in other actions
form.addEventListener("submit", (e) => {
  e.preventDefault();
  isSubmitted = true;
});

// Once the form is submitted once, only then 
// trigger programmatically the actual behaviour
btn2.addEventListener("click", () => {
  if (isSubmitted) {
    form.submit();
  }
});

This way, you can also play with isSubmitted variable, and mark it again false, whenever someone does an action which requires additional confirmation from the form itself.

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!