I have this line of PHP code $data = json_decode($response, true); and $items = $data['items'] that is return json data from sepecific URL as below
{
"items": [
{
"family": "ABeeZee",
"variants": ["regular","italic"]
},
{
"family": "Abril Fatface",
"variants": ["regular","400italic","900"]
},
{
"family": "Advent Pro",
"variants": ["100","200","300","regular","500","600","700"]
}
]
}
And I create this foreach loop for retrieve the font family names and I put them into the select box the code work without a problem.
And I want to create another select box to retrieve the variants data according to each font family. I want when I select ABeeZee font, The Variant select box only shows regular and italic. And when I select Abril Fatface font, The Variant select box only shows regular,400italic and 900. How can I do this by using jquery?
<select name="font-family" id="fonts">
<?php
foreach ($items as $item) {
$font_names = $item['family'];
<option value="<?php echo $font_names; ?>"><?php echo $font_names; ?></option><?php
}
?>
</select>