It is possible to retrieve options for a checkbox, dropdown or radio element from an external JSON URL. This is useful to create dynamic options that change by day, for example.
First, set the element option Options_source to JSON. The below input field must contain a valid JSON file. If the file isn’t a valid JSON file (you can test this with a JSON online formatter) or your webserver can’t retrieve an external file, the default options will be shown.
A simple JSON file looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
{ "options": [ { "text": "Option label 1", "value": 1, "id": "opt1" }, { "text": "Option label 2", "value": 2, "id": "opt2" }, { "text": "Option label 3", "value": 3, "id": "opt3" } ] } |
You can also attach images to options like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
{ "options": [ { "text": "Option label 1", "value": 1, "image": "https://ez-form-calculator.ezplugins.de/wp-content/uploads/ez-logo-152x152.png" }, { "text": "Option label 2", "value": 2, "image": "https://ez-form-calculator.ezplugins.de/wp-content/uploads/2015/05/14956851150_cf27c733bf_n1-1.jpg" }, { "text": "Option label 3", "value": 3, "image": "https://ez-form-calculator.ezplugins.de/wp-content/uploads/2015/05/15561483507_095d320602_n1-1.jpg" } ] } |