These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Drop Down tabulation

katmetz
Registered: Nov 29 2011
Posts: 7

I am new to Lifecycle and to this whole create your own form thing. I am trying to do a very simple task, but I have no idea what i am doing. All I am trying to do is tabulate the number of times each instance within a drop-down list is selected by the form filler. I tried using a formula that I found on another post, but I can't get it to pull from my drop downs.
 
I am creating a time card. It has 7 "Types" to choose from Regular, Holiday, PTO, etc.. for each day of the pay period (2 weeks).(this is not created as a chart) I am trying to come up with a summary of how many hours were worked in each Type based on the information selected in the drop downs by the form filler.
 
I applied the following formula to the totals text box(nCount1). This is just the formula used to calculate the Regular hours selected in the drop downs by the form filler. I would use a similar formula for each type. I am using Formcalc.
 
var nCount1=0
 
for i=0 upto Type.all.length -1 do
if (Type[i].rawValue eq "Regular") then
nCount1 = nCount1 + 8
endif
endfor
 
The formula has no errors, but it is not pulling from my drop downs. The total is remaining at 0
 
I hope this made sense..
Thanks for any help.
 

K. Harrison

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

I hope I understood what you're trying to achieve.

1. Create form variables for your individual counts (nCount1...nCount8) under the form properties (file > form properties > variables).

2. In the change:Event of your DDL add this FormCalc script:
  1. if (xfa.event.change eq "Regular") then
  2. nCount1 = nCount1 + 1
  3. elseif (xfa.event.change eq "Holiday") then
  4. nCount2 = nCount2 + 1
  5. elseif (xfa.event.change eq "PTO") then
  6. nCount3 = nCount3 + 1
  7. endif
  8.  
  9. TextField1 = Concat("Regular:", nCount1, " | Holiday:", nCount2, " | PTO:", nCount3)

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

katmetz
Registered: Nov 29 2011
Posts: 7
I am having an issue with this. If I fill out the form, and then change my mind about one of my previous selections. It doesn't update the count, rather it just adds the change.

Example: If I select Regular for all my hours, it totals 40 hours under regular. If I change one of the days to Holiday. Regular still reads 40 and then holiday reads 8.
Do I have a setting wrong. How can I fix this?


K. Harrison

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Ahhh ok ... you use several drop downs, I missed out that fact.

Then forget the previous solution.
Assumed the dropdowns have the same name (dropdown[0], dropdown[1]...) then you can use a loop to count the values.

Sample to loop through seven (7) dropdowns named "DropdownList1". Put this script (FormCalc) into the calculate:Event of a text field!
var cRegular = 0var cHoliday = 0var cPTO = 0 for i=0 upto 6 dovar iDDL = DropdownList1[i].rawValueif (iDDL eq "Regular") thencRegular = cRegular + 1elseif (iDDL eq "Holiday") thencHoliday = cHoliday + 1elseif (iDDL eq "PTO") thencPTO = cPTO + 1endif

endfor

 $ = Concat("Regular:", cRegular, " | Holiday:", cHoliday, " | PTO:", cPTO)

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs