Creates a checkbox on the screen with the initial checked boolean value and referenced by the given id at default location (0,0).
Some apps require the user to check a box if they agree with something, like an app privacy statement.
Retrieve and display a checkbox value.
// Retrieve and display a checkbox value.
checkbox("agreeBox", false);
textLabel("agreeLabel","I agree to the above privacy statement.","agreeBox");
textLabel("response1","Response: ");
textLabel("response2","");
onEvent("agreeBox", "click", function() {
setText("response2",getChecked("agreeBox"));
});
// Create a basic privacy statement checkbox.
checkbox("agreeBox", false);
textLabel("agreeLabel","I agree to the above privacy statement.","agreeBox");
checkbox(id, checked)
| Name | Type | Required? | Description |
|---|---|---|---|
| id | string | The unique identifier for the screen element. Must begin with a letter, contain no spaces, and may contain letters, digits, - and _. | | |
| checked | boolean | Whether the checkbox is initially checked. |
No return value. Modifies screen only.
setText(), showElement(), hideElement(), deleteElement(), setPosition(), setSize(). getText(), getXPosition(), getYPosition().Found a bug in the documentation? Let us know at documentation@code.org