javascript - JSON object call params as variables -
this question has answer here:
okay here's problem have bunch of price ranges made using json object want dynamically change json object call in example:
json object:
ranges = { "range0" : { "olive" : {"price": 5}, "ebony" : {"price": 8}, "tigerebony" : {"price": 8}, "zebrawood" : {"price": 7}, "mahagony" : {"price": 7}, "pinkivory " : {"price": 7} }, "range1" : { "olive" : {"price": 7}, "ebony" : {"price": 10}, "tigerebony" : {"price": 10}, "zebrawood" : {"price": 9}, "mahagony" : {"price": 9}, "pinkivory " : {"price": 9} } }
and problem:
$("handler").click(function(){ $("#range").html(ranges.range_var.material_var.price)//i know extremly wrong }):
i trying substitute .range_var
, .material_var
for variables holding correct value change according user's choice?
you need use bracket notation:
ranges[range_var][material_var].price
Comments
Post a Comment