PDA

View Full Version : Ext.getCmp(variable) ??



parsbin
12 Mar 2012, 5:24 AM
hi
i want to use variable as element id in Ext.getCmp(variable)
example:



var left = res_left_right[0] ;
var right = res_left_right[1] ;
Ext.getCmp(left).setValue(right);


but i received: "Ext.getCmp(left) is undefined" error
how can i use it?

mitchellsimoens
12 Mar 2012, 6:35 AM
You are trying to use getCmp to return an Element?

parsbin
12 Mar 2012, 9:51 AM
yes
i want to set value for some elements

mitchellsimoens
12 Mar 2012, 10:04 AM
You should use Ext.get to get the Element

xiinteractive
12 Mar 2012, 7:39 PM
use Ext.getCmp('myFieldID').setValue to set the value of an element by calling its ID.... like if you are calling a form element.

It looks like what you are doing is just changing the value of a variable in javascript.. .. don't need the Ext.gertCmp for that

And of course, if you were calling the ID of the element with Ext.getCmp('myFieldID').setValue(myVar) then you would be using the value of the variable (your var left and var right) into the value of the particular element 'myFieldID'

parsbin
12 Mar 2012, 11:08 PM
use Ext.getCmp('myFieldID').setValue to set the value of an element by calling its ID.... like if you are calling a form element.

It looks like what you are doing is just changing the value of a variable in javascript.. .. don't need the Ext.gertCmp for that

And of course, if you were calling the ID of the element with Ext.getCmp('myFieldID').setValue(myVar) then you would be using the value of the variable (your var left and var right) into the value of the particular element 'myFieldID'

see I just want to use variable instead of string in "Ext.getCmp(left).setValue(right)"
I mean I want "left" and "right" be variables not a fix string I do not want to change anything .
i want use a variable as a form ElementID in setVlue