PDA

View Full Version : Get Value from TextArea



Vepe
8 Feb 2010, 2:48 AM
Hi!

I'm a little bit newbie with extjs and javascript and I'm having a little problems to get the value of the textarea in a forumlaire...

My Code is like this:


I have a forumulaire



var form = new Ext.FormPanel({
region: 'center',
labelWidth: 200, // label settings here cascade unless overridden
url:'AddTuple.action',
method: 'POST',
autoScroll: true,
reader: reader,
waitMsgTarget: true,
bodyStyle:'padding:15px 5px 0px 5px',
defaultType: 'textfield',
items: [
new Ext.form.FieldSet({
title: 'New',
autoHeight: true,
defaultType: 'textfield',
defaults: {width: 400},
items: [
{xtype: 'hidden', name: 'table', value:'FM_COMMENT'},
{xtype: 'hidden', name: 'identify', value:'ID_COMMENT'},
{xtype: 'hidden', fieldLabel: 'ID_COMMENT', name: 'ID_COMMENT', value: 'FM_COMMENT_SEQUENCE.NEXTVAL'},
{xtype: 'textarea', fieldLabel: 'COMMENT_TEXT', name: 'COMMENT_TEXT'}
],

.........




How do I get the value from this textarea


I was trying to do like this

form.getComponent('COMMENT_TEXT'), but it isn't working...


Thanks for everything!
Bye!

tobiu
8 Feb 2010, 3:17 AM
hi Vepe,

try:



var textArea = form.getForm().findField('COMMENT_TEXT');


it is important to enter the BasicForm first.

kind regards,
tobiu

mzkr
8 Feb 2010, 6:16 AM
Ext.getCmp( String id ) should work....

Eugen_
8 Feb 2010, 8:10 AM
{xtype: 'textarea', fieldLabel: 'COMMENT_TEXT', id: 'COMMENT_TEXT', name: 'COMMENT_TEXT'}


form.findById('COMMENT_TEXT')

tobiu
8 Feb 2010, 8:16 AM
@mzkr and eugen_:

you should prefer findField(). imagine you create multiple forms with the same constructor. then you can't use id that easy (you could create them dynamically and pass the value...), but with findField() it is enough to know the name (or hiddenName) of a field.

kind regards,
tobiu

Vepe
8 Feb 2010, 10:34 AM
Thank you!!! Now it's working =D!!!

mzkr
11 Feb 2010, 6:38 PM
But somewhere I read that finding by ID is much more faster then name.

Also, Finding by ID will make sure that you have unique field.

Am I correct?

JeanNiBee
11 Feb 2010, 7:20 PM
But somewhere I read that finding by ID is much more faster then name.

Also, Finding by ID will make sure that you have unique field.

Am I correct?

ID search is faster, but in this case I'm sure it does not make much of a difference. Also ID doesn't guarantee uniqueness. If they are generated by the framework they should be unique <b>but</b> you can still supply an ID value yourself and create duplicates.

If you have fields / components with the same ID my understanding is that you get the last one rendered if do a getCmp(id);