2
Ceci est probablement incroyablement basique. Dans le code ci-dessous, j'ai annoté la partie qui a besoin d'attention. Je ne sais pas comment le structurer si, au lieu de res.DATA.VALUE [i], je le rend dynamique et écris 'res.DATA'. + TextCol + '[i]' (pseudocode pur, je me rends compte qu'il ne fonctionnera pas)Accéder dynamiquement à la valeur JSON
function loadSelect(entity,textCol,retField,method) {
var thisid;
var thisval;
var textCol = textCol.toUpperCase();
$.getJSON("/cfcs/system.cfc?method=" + method + "&returnformat=json",{},function(res,code) {
if(res && res.ROWCOUNT > 0)
{
for(var i=0; i<res.ROWCOUNT; i++){
thisid = parseInt(res.DATA.RECORD_ID[i]);
thisval = res.DATA.VALUE[i]; //instead of VALUE, I want to use the textCol argument passed to this function.
..../snip
doux , Merci mon ami – Paul