View Full Version : el.getValue() but no el.setValue()

19 Apr 2007, 5:18 PM
What am I missing I can't set the value or id of any basic DOM element but I can get it, that's odd ... any ideas when this will be supported ?


var el = Ext.get('myButton); // get the value of myButton

var getVal = el.getValue();

alert(getVal); // display it.

But I can't set it ?

var setValue = el.setValue("myNewValue"); // doesn't exist ? :((

19 Apr 2007, 6:19 PM
from the docs under Ext.Element:
set(Object o, [Boolean useSet]) : Ext.Element Element
Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)i.e. the set() method is pretty comprehensive.

so in your case, use this:
var modified = el.set({
id: 'myNewId',
value: 'myNewValue'

19 Apr 2007, 6:28 PM
I haven't test it but trying Ext.get('myNewValue').dom.value = value;

19 Apr 2007, 6:34 PM
xmrcivicboix, that will definitely work 'cos it's poking the DOM directly. ;)

alternative to that is to use getDom() to return a DOM reference, but it's a little more tedious for handling the case above i.e.
Ext.getDom('myNewValue').id = 'newId';
Ext.getDom('newId').value = 'newValue';