# Slider programmatic update

**URL:** <https://discourse.processing.org/t/slider-programmatic-update/30651>\
**Category:** Coding Questions\
**Created:** [June 11, 2021, 1:08pm UTC](https://discourse.processing.org/t/slider-programmatic-update/30651 "2021-06-11T13:08:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyP5](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@AndyP5](https://discourse.processing.org/u/AndyP5)\
**Post date:** [June 11, 2021, 1:08pm UTC](https://discourse.processing.org/t/slider-programmatic-update/30651/1 "2021-06-11T13:08:04Z")

</div>

Hi there,

I am looking to programmatically update position of a slider. I would like to have the slider manual user action, but also step the slider in response to a button press.  
Is this possible or do I need to re-create the slider each time I update it?

---

<div class="post-metadata">

**Author:** ![AndyP5](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@AndyP5](https://discourse.processing.org/u/AndyP5)\
**Post date:** [June 11, 2021, 2:30pm UTC](https://discourse.processing.org/t/slider-programmatic-update/30651/2 "2021-06-11T14:30:51Z")

</div>

This worked!

```auto
function updateButtonState() {
    if (buttonState == true) {
      slider.value(200);
      buttonState = false;
    } else {
      slider.value(20);
      buttonState = true;
    }
  }

```
