arrays - Get specific values form JSON Table with javascript over IDs -
i have following problem:
i have json table data need (found on internet since need)
var testext ={"key1":[ { "firstname":"ray", "lastname":"villalobos", "joined":2012 }, { "firstname":"john", "lastname":"jones", "joined":2010 } ]} document.getelementbyid("demo").innerhtml=testext.key1[0].firstname;
this works fine can see still need index [0] dataset need.
i need to without index...
like here:
var testext = { "key1": ["string1/1", "string1/2" ], "key2": ["string2/1", "strin2/2"] }; document.getelementbyid("demo").innerhtml = testext['key1'][0];
just combined variable :
document.getelementbyid("demo").innerhtml = testext['key1'].['firstname'];
anyone idea on how can this?
thanks in advance.
you correct. restructure array associative array of associative arrays. can call them array_name['first_index']['second_index']
.
var testext = { "key1": { "firstname": "ray", "lastname": "villalobos", "joined": 2012 }, "key2": { "firstname": "john", "lastname": "jones", "joined": 2010 } }; document.getelementbyid("demo").innerhtml = testext['key1']['firstname'];
<div id="demo">default</div>
Comments
Post a Comment