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

Counting Text Fields in a Table

wendye
Registered: Jan 21 2008
Posts: 5

I need to count the filled in text fields in a table to show the number of days an employee is working each week.
 
i.e. If the employee works 2 days one week, I need it to show 2 in the Days column. If the employee works 4 days the next week, I need it to show 4 in the Days column.
 
Can anyone help with a formula/script?
 
Thanks!

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Have you looked at the "HasValue" function to test to see if a given field has and entry or not?

Assuming your fields in a row are named "Monday", "Tuesday", "Wednesday", "Thursday", and "Friday":

var Count = 0
if(HasValue(Monday)) then
Count = Count + 1
endif

if(HasValue(Tuesday)) then
Count = Count + 1
endif

if(HasValue(Wednesday)) then
Count = Count + 1
endif

if(HasValue(Thursday)) then
Count = Count + 1
endif

if(HasValue(Friday)) then
Count = Count + 1
endif

Count

George Kaiser

wendye
Registered: Jan 21 2008
Posts: 5
I'm not very familiar with coding/scripting so this is all pretty foreign to me.

I created a calendar in a table where I need to add the number of hours per week in one column (which I've done) and also then add the number of days working per week in another column.

I tried the above script and it didn't work. Do I need to do something with the table name and specific row for each row needed?

I don't know if it matters, but my fields for the days are labeled M1, T1, W1, Th1, F1 for the first row I need to calculate; M2, T2, W2, Th2, F2 for the second row, etc.