# CheckBox

## **CheckBox**

A checkbox that can be checked (value: 1) or not (value: 0). For example, if you have an items application. You can use checkbox to show its availability.

## Demo

{% embed url="https://youtu.be/Z72Ao2Pge5c" %}

## Documentation

Gebra Suite app configurations allows you to add different controls in your app. Check box is the easiest control. Its general properties are described below

## General Properties

These properties defines how control behaves in Gebra Suite.

* Control Type

\- For using Check box control, "Check Box" control type should be selected from drop down list.

* Control Id

\- For each Gebra Suite app, this id should be unique. For Example: "\_abcdef". Gebra Suite allows you to change its value only once. You can change this id to any value but it should be meaningful. Recommended way is to start with mandatory prefix(set in app). It can contain numbers, underscores, uppercase and lowercase letters. Gebra Suite saves checkbox value in one bit.

* Label

\- It is the display value for control. For checkboxes, it makes sense to label them like "isAvailable" in the form of Yes/ No questions

* Data

\- This property specifies from where this control gets data. To set it, specify the controlId of data source. By default "Not in Database" option is selected.

* Refers to Config

\- You need to set this option if this is a field, that other fields refer to, to get data from another config.

* Default value

\- This value is set when an application is opened or a new record is created.

### Tutorial

This tutorial assumes that a user has an existing app and they want to add a new control of type "Check Box". First of all, select "Check Box" from list of controls. After that you need to give an id to your check box and create column in database. We also added two buttons "Set" and "Reset". For this tutorial we will follow the structure of demo given above.

We need to add code to our button "onClick" events. "Set" button will set the value of checkbox and "Reset" button will unselect it. Gebra Suite accepts input for setting/resetting checkboxes in following formats: as an integer (0,1), as a string "0 or 1", as a Boolean (true or false). The code snippet of Set button is given here

![Picture of a checkbox event](https://4275956601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOvU7jyPAQ0DefSlDf98E%2Fuploads%2Fgit-blob-b0912be67b9bb49b3b93347a07fb84bac4d1b617%2Fimage_checkbox_1.png?alt=media)

When set button is pressed, it sets the checkbox. Similar is the case when the reset button is clicked it will uncheck the checkbox. After clicking set button our app will look like this

![Picture of a checkbox](https://4275956601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOvU7jyPAQ0DefSlDf98E%2Fuploads%2Fgit-blob-8776045a4bb8516992195d858d0f05e47b3cc094%2Fimage_checkbox_2.png?alt=media)

In the last, there is one point you need to care about whenever you want to use true and false to set or reset the checkbox do it in these three ways 0, "0" or false. Do not use true or false as string values like "false" while setting the value of checkbox. It will result in unexpected behavior.
