javascript - how to get different values from an array? -
i sending encoded data array , trying retrieve them. using following code that
var holiday_list =<?php echo json_encode($calendar_results); ?>; var events = []; //the events array $.each(holiday_list, function(key, value) { events.push({ title: value.type, //get type(am or pm) start: value.date_cal, //date of calendar // classname: "fc-event-skin22" }); there 2 types. , pm. want results 1 variable , pm results 1 variable. if knows how give me idea. using php codeigniter framework. in advance.
you need "if-else". hope work.
var amevents = []; //the events array var pmevents = []; $.each(holiday_list, function(key, value) { if( value.type == 'am'){ amevents.push({ title: value.type, //get type(am or pm) start: value.date_cal, //date of calendar // classname: "fc-event-skin22" }); } else{ pmevents.push({ title: value.type, //get type(am or pm) start: value.date_cal, //date of calendar // classname: "fc-event-skin22" }); } });
Comments
Post a Comment