Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- get variables from different objects in json


daveVk - 1:05 am on Aug 2, 2012 (gmt 0)


The issue is knowing what price goes with what image, adding the id is the most direct way, if that can be done.

Using this ( the link element ) inside the [] will not work as a string such as 'firstOne' is expected.

A Map as Fotiman suggests is good idea.

To fit in with existing code

var thumbNo = 1;
map = ['firstOne', ....
var car=cars_data.haveAlook.TheThumbnails;
$(".vehicle_row a").each(function(){
var price = my_data.Range.SmallFamily[map[thumbNo-1]].price;
$(this).html('<img src="/comparetherange/images/' +
+ car['thumb'+thumbNo]
+ '" alt="">');
thumbNo++;
});


Thread source:: http://www.webmasterworld.com/javascript/4480672.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com