<cfscript>
var i = 0;
var l = ListLen(qry.Columnlist);
var FieldName = "";
for (i = 1; i lte l; i = i + 1) // you also can use i++ instead
{
FieldName = ListGetAt(qry.Columnlist, i);
form[FieldName] = qry[FieldName][1];
}
</cfscript>
上記のより良い(おそらく少し速い、本当に重いループの場合)バージョンを編集します:
<cfscript>
var i = 0;
var Fields = ListToArray(qry.Columnlist);
var FieldName = "";
var l = arrayLen(Fields);
for (i = 1; i lte l; i = i + 1) // you also can use i++ instead
{
FieldName = Fields[i];
form[FieldName] = qry[FieldName][1];
}
</cfscript>