Macro sc_block_display

Macro sc_block_display


In this example, we will see how to use the sc_block_display macro in an Ajax event using a Radio button on a Form, this macro is intended to hide or show a block.

The steps in this example:
  1. Configuring Radio type field
  2. Configuring and creating blocks
  3. Using Macro in Ajax Event


The macro has the following scope:

Calendar application
chart application
Grid application
Form application
Control Form
onAfterInsert
onAfterUpdate
onScriptInit
onLoad
onRefresh
onValidate
onValidateFailure
onValidateSuccess
onScriptInit
onScriptInit
onRecord
onAfterDeleteAll
onAfterInsert
onAfterInsertAll
onAfterUpdate
onAfterUpdateAll
onScriptInit
onLoad
onNavigate
onLoadRecord
onRefresh
onValidate
onValidateFailure
onValidateSuccess
onClick
onScriptInit
onLoadAll
onRefresh

Configuring Radio type field

1.We will be using a Radio type button as a flag to enable the block or disable it, that way we will be creating a Manual lookup to put two options available (Full and Simple)

1.1 Creating a radio button with the name "Filling"

Remember to disable the checkBox to create a new block to position this field

Configuring Manual Lookup of the Radio Field

1.2 With the field already created, choose the Manual Lookup option with the following labels (Full and Simple) with the following values respectively ("f" and "s"), as shown below:


After configuring each option, click on the "Include" button

In the onLoad event of your form, place the following code:
  1. {filling} = "s";
  2. sc_block_display('block2','off');

Configuring and adding blocks

2. We will be at this stage creating our block to be used in the macro.

2.1 In your form click on Layout-> Blocks

Create a block called "block2" as follows:



Organize your separate fields for each block in the Field Positioning option, with the following image:


Using the macro in Ajax event

3.Create an "onClick" ajax event and use the following code:
  1. if({filling} == 'f') {

  2.   sc_block_display('block2', 'on');

  3. else {

  4.   sc_block_display('block2', 'off');

  5. }
3.1Save and run the application.

When clicking on the option "Full", the entire block will be shown, and when clicking on the option "Simple" the block will be collapsed




    • Related Articles

    • Using the sc_field_display macro

      To dynamically hide a field in this example, the macro sc_field_display is used, which is responsible for hiding or dynamically displaying a field or several. This macro has scope in the following events: In this example, it will be used within an ...
    • Manipulate a button display dynamically

      The most interesting feature in Scriptcase, is the manipulation of the display of buttons in applications, with the macro sc_btn_display ("nomebotao", "on / off"): To see all the macro documentation click here. We can use this macro to validate ...
    • Macro sc_date

        Scriptcase provides a very useful macro for manipulating dates, which is a very laborious process, however with the use of the sc_date macro (Increments and Decrement Dates), it is much simpler, example:   sc_date (Date, format, operator, D, M, A) ...
    • Macro sc_error_continue

      When we want to insert, modify or delete a record within our form it can not be possible because of the database errors that are previously configured, which can be generated by ourselves by means of triggers, for example: In this example we create a ...
    • Using the sc_confirm macro

      In this article, see a practical example of using the sc_confirm macro. This macro can only be used on PHP buttons created in the toolbar of form and control applications, with the aim of confirming the action's excursion. See how to create a PHP ...