Get Toggle Switch State
Last updated
Last updated
Block Information
Available in: Page Flow
Toolbox Category: Input
Block Type: Output
Output Type: boolean (true/false)
Get Toggle Switch State
is an output block that allows you to retrieve the state of Checkbox and Toggle Switch elements on a page or form. The output is of type boolean (true/false) and is compatible with Value Parameters of type boolean (true/false) or of type any.
Refer to the Get Toggle Switch State in Data Design block for dynamically generated content.
The block comes in two modes which are discussed below.
The Mode 1 version of the Get Toggle Switch State block consists of a Selectable Input to choose the element you want to get the state of.
The Mode 2 version of the Get Toggle Switch State block consists of a Value Parameter that accepts either a text value in the form of a CSS Selector or an element value. The Element block comes pre-attached for your convenience but can be removed and customized.
The image below shows an example of the Mode 1 version where the the variable b is set to the state of the selected toggle switch or checkbox element.
In the next example we see a Mode 2 version where the variable b is set to the state of the selected toggle switch or checkbox element. This time the element is selected using a CSS Selector.
The next example shows a Mode 2 version, where the output of the block is used inside a If block and compared to the boolean value of true. The element itself is selected using the Element block.
If this condition is met, the function block do_something is invoked.
Lastly we have another example with a Mode 1 version. The output is used inside a If block and compared to the boolean value of true. If this condition is met, The Show Information Popup block is used to show a message that the switch is ON. The If block's else flow parameter also has a Information Popup block, but it will display the message that the switch is OFF.
NOTE: The same examples also apply for a Checkbox element.