I am returning a JSON array from my PHP class. Part of the code is as follows:
...
echo json_encode($users);
return json_encode($users);
?>
The echo statement of the above code is as follows:
[
{
"ID": "1",
"firstname": "Jane",
"school": "Frohj"
},
{
"ID": "2",
"firstname": "Mathew",
"school": "Lebrasky"
},
{
"ID": "3",
"firstname": "BAHUUU",
"school": "uni of kansas"
}
]
Now, in my html form i have a DROPDOWN.
<fieldset>
<legend>Selecting elements</legend>
<p>
<label>Select list</label>
<select id = "myList">
<option value = "1">I WANT TO DISPLAY USER'S NAME HERE</option>
<option value = "2">I WANT TO DISPLAY USER'S NAME HERE</option>
</select>
</p>
</fieldset>
I want to display users firstnames as the fields in the dropdown box. The values for this, is obtained from the JSON that was passed. Now how do i, retrieve the JSON and populate the dropdown box with firstnames of users.