I have two questions earlier in my interview, that work great together.
Essentially, the first question presents a list of countries, using the very amazing and highly useful countries_list() function. The second question then presents a combobox of potential states using the (also) very amazing and highly useful states_list() function, but modified to only show the states that might apply to the user, and modifies the label "State" as appropriate (and I have some other code that skips this question if there is only one state in the country (eg. Singapore) ).
---
question: |
What country do you live in?
fields:
- Country: jurisdiction.country
input type: combobox
code: countries_list()
---
question: |
What state do you live in?
fields:
- ${ subdivision_type(jurisdiction.country) }: jurisdiction.state
input type: combobox
code: states_list(jurisdiction.country)
---
What I'm wondering, is if there's a known way to accomplish this same effect "live" on a page using input type: ajax
(as here), custom JS, or some other method?
Ideally, I could "live reload" the question prompt with subdivision_type()
as well.
There is a similar example in the docassemble documentation here:
https://docassemble.org/docs/background.html#background_response_choices
This does not update the label of the State field using JavaScript, however. You could write your own JavaScript to accomplish that somehow.
Another possibility would be to use the strategy described in this section to refresh the screen when a user changes the country:
https://docassemble.org/docs/background.html#background_response_refresh