# XoopsFormCheckBox

```php
// Display checkbox, initially checked.
$checked_value = 1;
$checkbox1 = new XoopsFormCheckBox(, 'box1', $checked_value);
$checkbox1->addOption($checked_value, _MD_MODNAME_CHECK_ME);
$form->addElement($checkbox1);


// Display checkbox, initially unchecked.
$checked_value = 1;
$checkbox2 = new XoopsFormCheckBox(, 'box2', !$checked_value);
$checkbox2->addOption($checked_value, _MD_MODNAME_CHECK_ME);
$form->addElement($checkbox2);
```

Assuming the form's method is POST:

If box 1 is checked, the submitted form will have $\_POST\['box1'] = 1. Otherwise $\_POST\['box1'] will be undefined.

If box 2 is checked, the submitted form will have $\_POST\['box2'] = 1. Otherwise $\_POST\['box2'] will be undefined.

![](/files/-MPw6w-ocItqP4hh4fwI)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xoops.gitbook.io/xoops-modules-cookbook/form-classes/forms/xoopsformcheckbox.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
