# How to change the state of a checkbox created with createCheckbox()?

**URL:** https://discourse.processing.org/t/how-to-change-the-state-of-a-checkbox-created-with-createcheckbox/24514
**Category:** Beginners
**Created:** [October 11, 2020, 9:50am UTC](https://discourse.processing.org/t/how-to-change-the-state-of-a-checkbox-created-with-createcheckbox/24514 "2020-10-11T09:50:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sipe40](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@sipe40](https://discourse.processing.org/u/sipe40)
#### Post date: [October 11, 2020, 9:50am UTC](https://discourse.processing.org/t/how-to-change-the-state-of-a-checkbox-created-with-createcheckbox/24514/1 "2020-10-11T09:50:01Z")

</div>

Hi!

I’ve created a checkbox using `box1 = createCheckbox('test', true);` and I want to be able to change the state of that checkbox. However, `box1.elt.checked` returns `undefined`. This seems to be, because `box1.elt` returns the checkbox wrapped in a div.

```auto
<DIV>
 <INPUT type="checkbox" id="jxl7300rqxa"></INPUT>
 <LABEL for="jxl7300rqxa">test</LABEL>
</DIV>

```

How can I access the input div and be able to change the `.checked` state?

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [October 11, 2020, 12:57pm UTC](https://discourse.processing.org/t/how-to-change-the-state-of-a-checkbox-created-with-createcheckbox/24514/2 "2020-10-11T12:57:55Z")

</div>

> [@sipe40](#):
>
> How can I access the input div and be able to change the `.checked` state?

Can’t you just call method **checked()** over variable _box1_?

- [reference | p5.js](http://p5js.org/reference/#/p5/createCheckbox)

```auto
box1 = createCheckbox('test', true);
box1.checked(true);
print(box1.checked());

```

---

<div class="post-metadata">

### Author: ![sipe40](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@sipe40](https://discourse.processing.org/u/sipe40)
#### Post date: [October 11, 2020, 1:06pm UTC](https://discourse.processing.org/t/how-to-change-the-state-of-a-checkbox-created-with-createcheckbox/24514/3 "2020-10-11T13:06:44Z")

</div>

Oh, that worked. Thought I tried that multiple times before, but guess I didn’t.

Thank you.
