var sum = 0 var symbol = '?' function total() { document.write("total: "+symbol+sum.toFixed(2)) } function table(data) { for (key in data) { var topic = data[key] document.write(""+topic["name"]+"
") document.write("") document.write("") document.write("") document.write("") document.write("") document.write("") document.write("") document.write("") for (key in topic["vendors"]) { var vendor = topic["vendors"][key] document.write("") var vendortotal = 0 var currency = vendor["currency"] if (currency == "USD") symbol = '$' for (key in vendor["categories"]) { var category = vendor["categories"][key] document.write("") for (key in category["items"]) { var item = category["items"][key] document.write("") document.write("") document.write("") document.write("") document.write("") var extended = parseFloat(item["quantity"])*parseFloat(item["price"]) document.write("") vendortotal += extended document.write("") } } document.write("") sum += vendortotal } document.write("
quantityitemdescriptionlist unit priceextended price
"+vendor["name"]+"
"+category["name"]+"
"+item["quantity"]+""+item["item"]+""+item["description"]+""+symbol+parseFloat(item["price"]).toFixed(2)+""+symbol+extended.toFixed(2)+"
total"+symbol+vendortotal.toFixed(2)+"
") } }