PDA

View Full Version : Set the properties dynamically from an array



Ashw!n
14 Dec 2010, 11:35 AM
var propertyNames = {'fieldLabel', 'minLength'};
var proetyValues = {'first Name','10'};


var options = {};

for(i=0, n= propertyNames.length; i<n ;i++){
options.propertyNames[i] = propertyValues[i];
}

new Ext.form.TextField(options);


Is this way possible to set the properties from an array or json dynamically.?
When I was using the property names are not substitued.

Any ideas?8-|

Ashw!n
14 Dec 2010, 12:22 PM
I got it.

Instead of . use []

options[propertyNames[i]] = propertyValues[i];