I am trying to loop through my json array and get the ItemName and Prices according to category when i select a particular category : Delicious Treats, Decoration and Entertainment and display them in a multiple drop down list. the code i wrote is getting all ItemName and prices for all categories in one select tag. heres my code
function data() {
var text = '{"DataArray":[{"ItemName":"Salmon Puffs","Price":5,"Category":"Delicious Treats"},{"ItemName":"Beans on Toast Sandwich","Price":200,"Category":"Delicious Treats"},{"ItemName":"Whole Mashed Potatoes","Price":50,"Category":"Delicious Treats"},{"ItemName":"Calamari","Price":20,"Category":"Delicious Treats"},{"ItemName":"Egyptian Decor Pack","Price":300,"Category":"Decoration"},{"ItemName":"Marie Biscuits","Price":80,"Category":"Delicious Treats"},{"ItemName":"Middle Eastern Decor Pack","Price":390,"Category":"Decoration"},{"ItemName":"Star Wars Decor Pack","Price":360,"Category":"Decoration"},{"ItemName":"Hipster Decor Pack","Price":350,"Category":"Decoration"},{"ItemName":"Pears shaped liked Apples","Price":1000,"Category":"Delicious Treats"},{"ItemName":"Flowers","Price":20,"Category":"Decoration"},{"ItemName":"Dance Floor","Price":60,"Category":"Entertainment"},{"ItemName":"Clowns","Price":20.35,"Category":"Entertainment"},{"ItemName":"Fire Dancers","Price":80,"Category":"Entertainment"},{"ItemName":"Cantina Band","Price":2000,"Category":"Entertainment"},{"ItemName":"Improved Salmon Puffs","Price":5,"Category":"Delicious Treats"}]}';
obj = JSON.parse(text);
}
for (i = 0; i < obj.DataArray.length; i++)
{
addOption(document.drop_list.item, obj.DataArray[i].Price, obj.DataArray[i].ItemName);
}
Any assistance will be highly appreciated. thanks

and get the ItemName and Prices according to category when i select a particular categorymeans. Do you mean like a dropdown menu with multiple<optgroup>s? I'll just write an answer assuming that's what you meant.