PDA

View Full Version : Question about retrieving form values in function - returning an object not values.



davisty
14 Oct 2011, 10:37 AM
Hello,

Im trying to retrieve form values inside my function. It is not retrieving the values. But the object of the field(I think).

The screen basically is a To/From dates that are to be passed into a print program. The fields are not part of a store. I know I not formatting the getform.getvalue correctly. I know that someone who has worked with this can spot it immediately

The code is as follows:



function doPrintDET(gridThisDET) {
var formprt = Ext.getCmp('prtform');
scfrdt = formprt.getForm().getValues('SCFRDT'];
sctodt = formprt.getForm().getValues('SCTODT');
scmail = formprt.getForm().getValues('SCMAIL');
scsubj = formprt.getForm().getValues('SCSUBJ');
formprt.el.mask('Printing...', 'x-mask-loading');
formprt.getForm().submit({
url : 'TAA002RP.PGM',
method:'POST',
params:{
MODE:'PRT',
SCFRDT:scfrdt,
SCTODT:sctodt,
SCMAIL:scmail,
SCSUBJ:scsubj,
SCUSER:'/%USER%/'
... ... ...


Some of this code is System i (AS/400) centric so it may not be familiar.

davisty
15 Oct 2011, 6:53 AM
Please help

Uberdude
17 Oct 2011, 2:22 AM
scfrdt = formprt.getForm().getValues('SCFRDT'];
sctodt = formprt.getForm().getValues('SCTODT');

The first line is not valid javascript as you have opened with a round bracket and closed with a square bracket!

getValues is a function (called with round brackets) which does not need any arguments, it returns an object keyed by the field names. You then access the property from here with square brackets. Also you should put "var" before the variable name or else you are creating an evil global variable.


var scfrdt = formprt.getForm().getValues()['SCFRDT'];


In fact you could do this more concisely without making variables for each form field (assuming the field names match the parameter values the server expects):



params : Ext.apply({ MODE: 'PRT', SCUSER: '/%USER%/'}, formprt.getForm().getValues())