I am trying to understand DOM scripting, so how would you do to display the testlink object content in a two column table? one column for the first three atributes ine one cell and the last one in a second cell?
Code:
// Example Objet en json
var TestlinkJson = {"id_source":"7315f47dba65515fca60c851d7065bc6","url_source":"http:\/\/news.yahoo.com\/s\/afp\/20060822\/od_afp\/chinacateringcultureoffbeat_060822074830","title_source":"Jail-theme teahouse becomes prisoner of own success in China - Yahoo! News","smartlinks_infos":[{"id_dest":"75effc69e8c68b389c65c67119463312","score":"126","deleted":"0","date":"1164279208","zone_cible":"151","manually_added":"0","url_dest":"http:\/\/news.yahoo.com\/s\/afp\/20060825\/od_afp\/malaysiahealthtoilets_060825160532","title_dest":"Malaysia calls for \"toilet revolution\" - Yahoo! News"}]}
//fonction de construction de SmartLinks
// notice we're now using JSON as the init data
function TestLink(json_init)
{
// init data is used from the init object, e.g. json_init.property
this.url_source = json_init.url_source; //l'url du document source du SmartLinks
this.title_source = json_init.title_source; // titre du doc source du SmartLinks
this.id_source = json_init.id_source; //l'id de la source du SmartLinks
// notice Array() -- you need to use the proper constructor
// to actually create an array
this.smartlinks_info = new Array(); //tableau de liens cible avec info sur la zone, la date etc...
}
// note I changed the name of the instance var to avoid confusion
var testLinkInstance = new TestLink(TestlinkJson);
// this will alert saying '[Object]' or something similar,
// since you are attempting to alert with an entire object
alert(testLinkInstance);
|