🏠 back to Observable

Is it possible to set an input's "value" as a variable from another cell?


It’s very possible I am screwing up something simple here, but is something like workable?

viewof minChartDate = date({
title: “Minimum date”,
min: d3.min(myArray, d => d.date),
max: new Date(),
value: d3.min(myArray, d => d.date)

If so, it might be helpful to include an example in the inputs documentation, for fools like me.


Could you link to your notebook? Setting value from another cell is working fine for me:


Ah. Thanks for the example. The difference is that you are using date strings and I am using date objects. Your strings appear to be working, and my objects appear to be not.


Ah, yeah, that would do it. I tried Date objects first as well. FWIW you can easily convert a Date object into that format with dateObj.toISOString().slice(0, 9).


I’d be careful about using date.toISOString, since that will format the dates in UTC time rather than local time; that might give you the wrong date.

Here’s a function that will format a date as required by HTML:

You can also use d3-time-format:

format = d3.timeFormat("%Y-%m-%d")


Thanks for the remedial education. I needed it here.