Share via

How Do I Hide/Show HTML Buttons using JavaScript

abiodunajai 396 Reputation points
2023-07-18T17:45:30.1033333+00:00

Please I have two buttons on my forms, the first is to Process while the Second is to Submit.

  1. I want the Submit Button (Second button) to be hidden at Form load.
  2. I want the Process Button (First button) to be visible at Form load.
  3. When the Process Button is clicked, it should become invisible while making the submit button to be visible.
  4. The Process button(First button) after it has been clicked, should remain invisible until the user refresh the page/load the page.

How do I handle this in the JavaScript.

My Html is pasted below

               <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <button type="button" class="btn btn-primary" onclick="ReceiptDialog(this, 'ReceiptTypeCode');">Process</button>
                        <a href="#dialog3" class="btn btn-primary" style="float:right" title="Confirm" data-toggle="modal" onclick="dialog3();">Receipt</a>
                    </div>
                </div>

Please note that ReceiptDialog() is a modal popup and diaglog3() is a modal submit confirmation (Y/N).

Any assistance will be greatly appreciated.

Best regards,

Abiodunajai

Microsoft 365 and Office | Development | Office JavaScript API
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

Developer technologies | ASP.NET Core | Other
0 comments No comments

Answer accepted by question author

Bruce (SqlWork.com) 84,071 Reputation points
2023-07-18T18:17:17.4033333+00:00

looks like you are bootstrap 5, the class name "d-none" is used to hide elements. add this to hide, remove to show

$("#id").addClass("d-none"); // hide
$("#id").removeClass("d-none"); // show

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.