How Do I Hide/Show HTML Buttons using JavaScript

abiodunajai 371 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

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,253 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,330 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
909 questions
C#
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.
10,417 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 58,206 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


0 additional answers

Sort by: Most helpful