In jsp, if there is a hidden variable, we do this in js:
document.getElementById('hiddenVarId').setValue = 'xxx';
What is the extjs equivalent of document.getElementById().setValue = 'xxx';
getElementById() is a quick way to access an element. Unlike the querySelector() method, the getElementById() is only available on the document object, not other elements. In this syntax, the id is a string that represents the id of the element to select. The id is case-sensitive.
HTML DOM Document getElementById() The getElementById() method returns an element with a specified value. The getElementById() method returns null if the element does not exist. The getElementById() method is one of the most common methods in the HTML DOM.
Class. Description. Ext.dom.Element. Main class in Ext JS that wraps single HTML DOM element. It includes DOM manipulating methods with normalizing cross-browser issues so that programmers do not have to worry about cross-browser issues.
Ext.get('hiddenVarId').set({value: 'xxx'});
This another possibility that leverages the ExtJS method set()
. This way you can set multiple attributes on an Ext.Element at once if that's something you also require now or later.
http://dev.sencha.com/deploy/dev/docs/?class=Ext.Element
Ext.get('hiddenVarId').dom.value = 'xxx';
Ext.get returns an Ext.Element
which has the actual DOM object in the dom
property. You can then directly assign to the value
property.
Ext.getCmp('hiddenVarId').setValue('xxx');
Ext.get() vs Ext.getCmp()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With