Zuke
September 30, 2009, 9:35am
1
Hi all
Im having trouble retreiving the value of fields contained within forms inside a tabform.
I have a loop giving me an array of form names within a tabform, then a nested loop which gives me the fields on each given form.
My problem is this
I can get the field value by using the complete form field naming
application.output(forms.filter_criteria_comp_det.com_det_ad_analysis_code.valueOf())
also I can get the same result with
application.output(forms[form_name].com_det_ad_analysis_code.valueOf())
where [form_name] is a variable contaning an item from an array of form names
however I cannot get a value when trying to use a variable as a field name from an array of fields
application.output(forms[form_name].[form_field].valueOf())
I dont know if im using the wrong notation, but the valueOf() statements throws an error each time i attempt this
Could someone advise me on the correct syntax for this
Regards
McCourt Cordingley
ROCLASI
September 30, 2009, 9:39am
2
Hi McCourt,
Zuke:
application.output(forms[form_name].[form_field].valueOf())
I dont know if im using the wrong notation, but the valueOf() statements throws an error each time i attempt this
Could someone advise me on the correct syntax for this
You are using a period too many:
application.output(forms[form_name].[form_field].valueOf())
should be
application.output(forms[form_name][form_field].valueOf())
Zuke
September 30, 2009, 9:45am
3
Hi
Thanks for the feedback
However im still getting the same error without the extra period
application.output(forms[form_name][form_field].valueOf())
TypeError: Cannot call method “valueOf” of undefined
McCourt Cordingley
ROCLASI
September 30, 2009, 9:48am
4
Hi McCourt,
Can you check what the values are when you get the error?
Zuke
September 30, 2009, 9:54am
5
Hi ROCLASI
You are completely correct,
It turns out my error was related to my arrays
My form array index starts at 1
However i had incorrectly began my field array index at 0 which obviously meant the valueOf() was referencing an empty array element.
Having began my field array at 1 instead of zero i now get the desired form field values.
Many thanks for the input
McCourt Cordingley