# How do I enable/disable a selection box?

**URL:** <https://discourse.processing.org/t/how-do-i-enable-disable-a-selection-box/20656>\
**Category:** Coding Questions\
**Created:** [May 9, 2020, 3:01am UTC](https://discourse.processing.org/t/how-do-i-enable-disable-a-selection-box/20656 "2020-05-09T03:01:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bassam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@Bassam](https://discourse.processing.org/u/Bassam)\
**Post date:** [May 9, 2020, 3:01am UTC](https://discourse.processing.org/t/how-do-i-enable-disable-a-selection-box/20656/1 "2020-05-09T03:01:25Z")

</div>

Is this possible?

I know that I can disable options in a selection box via .disable(option) but I’d like to be able to enable/disable the box itself.

---

<div class="post-metadata">

**Author:** ![Sven](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sven/32/8293_2.png) [@Sven](https://discourse.processing.org/u/Sven)\
**Post date:** [May 9, 2020, 6:57am UTC](https://discourse.processing.org/t/how-do-i-enable-disable-a-selection-box/20656/2 "2020-05-09T06:57:19Z")

</div>

Yes, it’s possible. One cool aspect of p5.js is that it builds upon web technologies. Everything is just HTML, CSS, and JavaScript. Your select box is a HTML `<select>` element. To disable it, you have to set the [disabled attribute on that element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#attr-disabled). Like this:

```javascript
  mySelect = createSelect();
  mySelect.attribute('disabled', true);

```

---

<div class="post-metadata">

**Author:** ![Bassam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@Bassam](https://discourse.processing.org/u/Bassam)\
**Post date:** [May 11, 2020, 3:51am UTC](https://discourse.processing.org/t/how-do-i-enable-disable-a-selection-box/20656/3 "2020-05-11T03:51:05Z")

</div>

I think this .attribute function is the most useful thing I have learned about p5.js and somehow it’s the first time that I’m learning of it. It’s suddenly become clear to me how powerful this library really is.

---

<div class="post-metadata">

**Author:** ![Bassam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@Bassam](https://discourse.processing.org/u/Bassam)\
**Post date:** [May 12, 2020, 5:22pm UTC](https://discourse.processing.org/t/how-do-i-enable-disable-a-selection-box/20656/4 "2020-05-12T17:22:44Z")

</div>

For some reason I’m unable to change the disabled attribute more than once.  
I can disable the select box but cannot re-enable it.

mySelect.attribute(‘disabled’,false);  
doesn’t work for some reason.

What am I doing wrong here?

[https://editor.p5js.org/Bassam/sketches/PxWpubFb6](https://editor.p5js.org/Bassam/sketches/PxWpubFb6)

---

<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:** [May 12, 2020, 5:34pm UTC](https://discourse.processing.org/t/how-do-i-enable-disable-a-selection-box/20656/5 "2020-05-12T17:34:46Z")

</div>

> [@Bassam](#):
>
> I can disable the select box but cannot re-enable it.

> **[reference | p5.js](https://p5js.org/reference/#/p5.Element/removeAttribute)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.
