I am trying to update multiple elements at once in a multidimensional array/object and having errors with .push and other options I have tried.
var FEtypes= {
textTemplate: {
type :"Text",
size : 50,
required : "no",
FEadd : '<input>',
label : 'Label',
top : 0,
left : 0
},
textareaTemplate: {
type : "Textarea",
cols : 30,
rows : 5,
FEadd :'<textarea>'
}
}
This works, but trying to do in one line.
FEtypes[1].left = someVariable1;
FEtypes[1].top = someVariable2;
I have been unsuccessful with:
FEtypes[1].push( {left:someVariable1, top:someVariable2} );
I keep getting an error that this is not a function or it does nothing.
.pushis a function used for arrays (ex.["this", "is", "an", "array"]) and not objects..push()would still be the wrong choice because it adds a new element to the end of an array, it doesn't update an existing element.