User-Defined Choice Options
Respondents can add their own choice options to a Dropdown or Tag Box if the desired option isn't available. Click into the dropdown below and start typing a car brand. If the brand isn't found, a "Create 'X' item" command will appear. You can click it to save the entered text as a new choice. In this demo, custom choices are saved in the localStorage
and restore on page reload. Click the "Clear saved choices" button to delete the choices from the localStorage
.
To let users add custom choice options, set the allowCustomChoices
property to true
for an individual Dropdown or Tag Box question. By default, custom choices are only stored temporarily and will be lost once the browser page is closed. If you'd like to keep these custom choices longer, handle the onCreateCustomChoiceItem
event to save them to your own data storage. Within the event handler, you'll have access to both the new item being added and the list of previously added custom choices. You can store the new item, the existing ones, or both. Refer to the Code tab for a code example.