Web Analytics Made Easy -
StatCounter can I convert an object name into a variable? - CodingForum

Announcement

Collapse
No announcement yet.

can I convert an object name into a variable?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • can I convert an object name into a variable?

    ... at least that's what I think I'm trying to do...

    what I have is this function which reads the JSON attributes of crab_house, a JSON object:
    Code:
    $.getJSON( '../map/clients.json', function(data) {
                    $.each( data.crab_house, function(i, m) {                
    bizAdd= new google.maps.LatLng(m.lat, m.lng);
    var message =m.html;
    createMarker(bizAdd,message); 
                    });
    but what I would like to do is something like:

    Code:
    var bizId='crab_house';
    
    $.getJSON( '../map/clients.json', function(data) {
                    $.each( data.bizId, function(i, m) {                
    bizAdd= new google.maps.LatLng(m.lat, m.lng);
    var message =m.html;
    createMarker(bizAdd,message); 
                    });
    is it possible?

    thanks in advance...

  • #2
    Code:
    $.each( data[bizId], function(i, m) {

    Comment


    • #3
      ... could have sworn I tried that. thanks!

      Comment


      • #4
        use eval

        Comment


        • #5
          Originally posted by jeffharris View Post
          use eval
          Ugh. Never. Not if there's a way around it.
          Be yourself. No one else is as qualified.

          Comment

          Working...
          X