Skip to content

Integrating dynamic Inputs in HTML structure #1963

Answered by Fil
spandl asked this question in Q&A
Discussion options

You must be logged in to vote

You could use https://observablehq.com/framework/lib/generators

In a given code block (you don't need two different blocks here, although you can use two if you prefer):

```js
const dateSelector = Inputs.select(dateArray, {
  value: dateArray[dateArray.length - 1],
  format: (f) =>
    formatDate(f, {
      options: {
        dateStyle: "medium",
      },
    }),
  label: "Date",
});
const selectedDate = Generators.input(dateSelector);
```

this binds the selectedDate variable to the value of the dateSelector selector.

Then in markdown, display the selector:

    <div class='dashboard'>
      <header>
          <h1>Make Work Flow - Global View</h1>
          <div>${dateSelector}</div>
    

Replies: 1 comment 1 reply

Comment options

Fil
Apr 9, 2025
Collaborator

You must be logged in to vote
1 reply
@spandl
Comment options

Answer selected by spandl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants