JavaScript
$('#total').change(function(){
var data = document.getElementById('data');
selData = data.options[data.selectedIndex].text;
selData = selData == 'data' ? data1 : data2;
var dataStr = document.getElementById('total');
totData = dataStr.options[dataStr.selectedIndex].text;
obj = getObjects(selData, '', totData);
for (var i = 0; i < obj.length; i++) {
if (obj[i].total == total) {
document.getElementById("json").innerHTML += JSON.stringify(obj[i]);
}
}
});
data1 = [
{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"}
];
data2 = [
{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",...