Showing or hiding a page section

You can show and hide sections on an Edit page based on a user's selection. This example was contributed by Tim Colson.

The example use case:

  • The object has a picklist with the values Not a member (code NO) and Club member (code YES)
  • The page's Membership Info section should be shown if Club member is selected and hidden otherwise.

To accomplish this, follow these steps:

  1. In the page editor, add a script component with the following script to the Edit page (see Editing pages):
    function customizeEdit() {
       var sectionID = rbf_getSectionIdByTitle("Membership Info");
       var code = rbf_getPicklistCode("membership");
       rbf_showOrHideSection(sectionID , code=="YES");
       }
  2. Add onchange event handler to the picklist: customizeEdit();
  3. For consistency, add an onload event handler to the page: customizeEdit();

When the section is hidden, it looks like this:

When the section is shown, it looks like this: