Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Hide a button based on several page items not being null

Bob VOct 31 2024

I'm trying to hide a button based on a null value check of 5 page items.

I'm starting out by hiding the button on page load, and then using the DA to show it if all fields are not null.

My button static id is create_btn in a region called buttons

Here is my JavaScript expression.

function checkFields() {
  const field1 = apex.item("P4_NAME_MAIL").getValue();
  const field2 = apex.item("P4_ADDRESS_MAIL").getValue();
  const field3 = apex.item("P4_CITY_MAIL").getValue();
  const field4 = apex.item("P4_STATE_MAIL").getValue();
  const field5 = apex.item("P4_ZIP_MAIL").getValue();

  const buttonItem = apex.region("buttons").getItem("create_btn");

  if (field1 && field2 && field3 && field4 && field5) {
    // All fields are not null, show the button
    if (buttonItem) {
      buttonItem.show();
      buttonItem.setLabel("Submit");
    }
  } else {
    // One or more fields are null, hide the button
    if (buttonItem) {
      buttonItem.hide();
    }
  }
}

But when I test this the button is never showed? Thanks for any help.

Oracle APEX 24.1.1

Comments
Post Details
Added on Oct 31 2024
4 comments
270 views