...
- Add a Single/Multiple Answer Lookup Table:
- Click on the "Lookup Table Data" question
- Edit the following fields:
- Lookup Table: ignore that for now
- Value Field: what you want to save as an answer (usually an id or a code). For locations you can use site_code or @id.
- Label Field: what you want to display to the user. For locations you can use name
- (Optional) Filter: can be used to filter the locations displayed.
- The tricky part is now to modify the xml to point the question to the location table. To do so:
- Click on Tools / Edit Source XML on the top right corner of the form builder:
- In the XML search for a select1 node holding your lookup question. It should look like this:
In this example my lookup question is /data/location_loookup - Then in the expression <itemset nodeset="instance('products')/products/product">, replace the instance with the instance of your location. For example
- if you want to display the list of states: instance instance('locations')/states/state
- if you want to select display the list of districts of a previously selected state: instance('locations')/states/state[site_code=/data/state_selected]/districts/district
where /data/state_selected is the state previously selected.
- Click on Tools / Edit Source XML on the top right corner of the form builder: