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

180
Views
Disable 2 submit buttons in single form after clicking button

when having two submit buttons named submit and nopay, only one is working at a time. I need to disable both buttons after clicking and submitting the form.

<form enctype="multipart/form-data" method="post" action="
    <?php echo base_url();?>user/Purchases_ctrl/create_vendor_payment" onsubmit='disableButton()'>
  <div class="d-flex content-block mb-2 pt-4 justify-content-center">
    <button type="submit" name="submit" value="submit" id="submit" class="btn btn-outline-custom w-30 btn-sm submit-btn mr-3">Submit</button>
    <button type="submit" id="nopay" name="nopay" value="nopay" class="btn btn-outline-custom w-30 btn-sm submit-btn">No Vendor Payments Today</button>
  </div>
</form>

<script>
  function disableButton() {
    var submit = document.getElementById('submit');
    var nopay = document.getElementById('nopay');
    submit.disabled = true;
    submit.innerText = 'SUBMITTING';
    nopay.disabled = true;
    nopay.innerText = 'No Vendor Payments Today';
  }
</script>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

<!DOCTYPE html>
<html>
<head>
    <title>Disable button using disabled property</title>
</head>
<body>
    <p>Click the button to submit data!</p>
    <p>
        <input type="submit" value="Submit" id="btClickMe" 
            onclick="disableButton(); this.disabled = true;" />
            <input type="submit" value="submit" onclick="disableButton(); this.disabled=true;" >
    </p>
    <p id="msg"></p>
</body>
<script>
    function disableButton() {
        var msg = document.getElementById('msg');
        var inputs = document.getElementsByTagName("INPUT");
            for (var i = 0; i < inputs.length; i++) {
                if (inputs[i].type == "submit") {
                    inputs[i].disabled = true;
                }
            }
        msg.innerHTML = 'Data submitted and the button disabled &#9786;';
    }
</script>
</html>

about 4 years ago · Juan Pablo Isaza Report

0

<script>
function disableButton(btn) {
setTimeout( () => {
  btn.disabled = true;
  btn.style.backgroundColor = '#36aeeb';
  btn.style.color = "white";
}) // No need to set a duration for the timeout

}

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!