JavaScript
$('#total').change(function(){
var data = document.getElementById('data');
selData = data.options[data.selectedIndex].text;
selData = selData == 'data' ? data : data1;
var dataStr = document.getElementById('total');
totData = dataStr.options[dataStr.selectedIndex].text;
console.log(getObjects(selData, '', totData));
});
data = [
{date: "A", quantity: 2, total: 190, tip: 100, type: "tab"},
{date: "B", quantity: 2, total: 190, tip: 100, type: "tab"},
{date: "C", quantity: 1, total: 300, tip: 200, type: "visa"},
{date: "D", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "E", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "F", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "G", quantity: 1, total: 100, tip: 0, type: "cash"},
{date: "H", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "I", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "J", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "K", quantity: 2, total: 200, tip: 0, type: "cash"},
{date: "L", quantity: 1, total: 200, tip: 100, type: "visa"}
];
data1 = [
{date: "m", quantity: 2, total: 190, tip: 100, type: "tab"},
{date: "n", quantity: 2, total: 190, tip: 100, type: "tab"},
{date: "o", quantity: 1, total: 300, tip: 200, type: "visa"},
{date: "p", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "q", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "r", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "s", quantity: 1, total: 100, tip: 0, type: "cash"},
{date: "t", quantity: 2, total: 90, tip: 0, type: "tab"},
...