Forums

How to make Dynamic Drop Down from JSON array

basharald 04 Apr, 2015
Hello,

I have a PHP page that returns a Json array of countries like this:

[code]{"Table":[{"ID":"1","Name":"Albania"},{"ID":"2","Name":"Afghanistan"}}[/code]


and i want to read this array and populate it to a DropDown inside my chronoForm.

How can i do that ?!

thank you,,
GreyHead 04 Apr, 2015
Answer
1 Likes
Hi basharald,

Use a Custom Code action in the form ON Load event and add the code to get your result:
<?php
$result = //some PHP here to return the Json array
$table = json_decode($result, true);
$form->data['countries'] = $table['Table'];
?>

Then you should be able to use the Dynamic Data tab in a Drop-down element in the Designer tab with these settings
Enabled : Yes
Data Path : countries
Value Key: ID
Text Key : Name

Bob
This topic is locked and no more replies can be posted.