# Synchronized inputs: setting a HTML view's value from a button

**URL:** <https://talk.observablehq.com/t/synchronized-inputs-setting-a-html-views-value-from-a-button/6044>\
**Category:** Help\
**Created:** [January 7, 2022, 4:42am UTC](https://talk.observablehq.com/t/synchronized-inputs-setting-a-html-views-value-from-a-button/6044 "2022-01-07T04:42:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fasiha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fasiha/32/5976_2.png) [@fasiha](https://talk.observablehq.com/u/fasiha)\
**Post date:** [January 7, 2022, 4:42am UTC](https://talk.observablehq.com/t/synchronized-inputs-setting-a-html-views-value-from-a-button/6044/1 "2022-01-07T04:42:52Z")

</div>

I was adapting the [Satellite Explorer / D3 / Observable](https://observablehq.com/@d3/satellite-explorer) notebook to have some presets, allowing for free dragging of the latitude/longitude/etc. parameters with also the ability to pick from certain presets. I should be able to use the `set` function described in the “Synchronized Inputs” example, but I can’t seem to set the `value` of a view in my attempt: [Satellite explorer with presets / Ahmed Fasih / Observable](https://observablehq.com/d/67d9299bb8d54ff0)?

When I click on one of the buttons—all of which should set the `rotation` view to a hardcoded value, `[200, 13, 0]`—the form’s `value` don’t get updated, though I do see the map blur for a moment before returning to full accuracy, _as if_ I’d changed the sliders.

This makes me think that I can’t mindlessly use the `set` function to set the HTML form’s `value` but I’m unsure how I should be tweaking it for this to work. I don’t think I need to encode the _event_ that’s dispatched do I?

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [January 7, 2022, 6:41am UTC](https://talk.observablehq.com/t/synchronized-inputs-setting-a-html-views-value-from-a-button/6044/2 "2022-01-07T06:41:21Z")

</div>

When the combined input’s value is changed programmatically, it doesn’t transfer to each of the sub-inputs. See how Inputs.form does it with a setter: [https://github.com/observablehq/inputs/blob/main/src/form.js#L25](https://github.com/observablehq/inputs/blob/main/src/form.js#L25)

or maybe you could base the combined input on Inputs.form? For a start:

> viewof rotate = Inputs.form([Inputs.range([-180, 180]), Inputs.range([-90, 90]), Inputs.range([-180, 180]) ])

---

<div class="post-metadata">

**Author:** ![fasiha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fasiha/32/5976_2.png) [@fasiha](https://talk.observablehq.com/u/fasiha)\
**Post date:** [January 7, 2022, 7:03am UTC](https://talk.observablehq.com/t/synchronized-inputs-setting-a-html-views-value-from-a-button/6044/3 "2022-01-07T07:03:47Z")

</div>

Thank you! The first suggestion didn’t seem to work, i.e., replacing `set` with this `set3`:

```auto
function set3(input, values) {
  // adapted from https://github.com/observablehq/inputs/blob/main/src/form.js#L25
  for (let i=0; i<3;i++){
    input.value[i] = values[i];
  }
  input.dispatchEvent(new Event("input"));
}

```

had the same behavior as before, but when I used `Inputs.form` as you suggested, with the original `set` from Mike’s “Synchronized Inputs” example, it works! Republished: [Satellite explorer with presets / Ahmed Fasih / Observable](https://observablehq.com/d/67d9299bb8d54ff0) 😊!

There must be something I don’t understand about HTML forms and look forward to digging into later. Again, many thanks!
