Wait for the DOM
Wrap your code in aDOMContentLoaded event handler so the form has finished rendering
before you query its inputs.
Read an input element
Each block in a Tally form has a stable UUID — you can find it by inspecting the rendered form in your browser’s DevTools. Pass that UUID todocument.getElementById() to get the
underlying input element.
Set a value on an input element
The form is a React app, so simply assigning to.value won’t update its state — React’s
synthetic event system needs to see a real input event. The snippet below uses the native
setter and dispatches a bubbling input event so React picks the change up.
Read previously entered answers
Tally persists in-progress answers to the browser’slocalStorage under a key derived from
the form ID. You can read them out at any time:
Events
Code injection has access to the same JavaScript events as embeds and popups, dispatched asCustomEvents on window rather than as postMessage payloads. See
Events for the full payload reference and listener patterns.