I have 7 DDLists for the availability of the employees for 7 days the week.
DD1, DD2, DD3, DD4, DD5, DD6, DD7
The list items for all are the same:
Day, Evening, Night, N/A(Not Available)
How I can calculate in a field the Total Days of Availability
and in a separate field Total Days N/A?
Thank you
Views
Replies
Total Likes
Hi,
First, my inclination would be to name all the DDLs the same--but label them differently. You can certainly do it using separate names as you have them now. but there is an advantage in having them the same as you will see. In the example blow, I have them all named DDLday, OK? So LiveCycle will look at them as: DDLday[0], DDLday[1] .... DDLday[6] (you will see this in the Hiearchy Pallet)
Also, I have specified values in the Binding Tab of the Object Pallet, such that N/A has a bound value of 0 (You can do this differently with only slight modification of the script needed).
Finally, on the "calculate" event of the number field that will display the days available, using FormCalc, use the following:
////////////////////////////////////////////////
var available = 0
var notAvailable = 0
for i = 0 upto 6 do
if(DDLday(i) > "0")then
available = available + 1
continue
else
notAvailable = notAvailable + 1
continue
endif
endfor
$ = available
NumNA = notAvailable
///////////////////////////////////////////
:
First, it declares a couple of variables to hold days available and days notAvailable and sets them both to zero
Second, it loops through all the DDLs and checks if the value is greater than 0. ("0" means notAvalable)
It adds a day to either available or notAvailable depending on > "0"
Then it displays the available number.
Finally, it puts the notAvailable in the other field named NumNA
This script will update when any of the DDLs are changed.
Hope this helps,
Stephen
Views
Replies
Total Likes
Hi Stephen
here is my form: https://acrobat.com/app.html#o
Can you check what I am doing wrong?
Thank you
Views
Replies
Total Likes
Hi,
The url you provided is not specific to your document--it is simply a link to acrobat.com--in other words, you need to go back and allow sharing of the document and post the url specific to the document.
Cheers,
Stephen
Views
Replies
Total Likes
Views
Replies
Total Likes
Hi,
A few things to correct
1) You must use square brackets -- My Fault -- not sure how that one got past me!
DDLday[i]
2) DDLs can't have values the same for the items meaning change them to:
0 = N/A, 1= Day, 2= Eve, 3= Nite
3) You only need the 1 script --don't place script on the NumNA field--delete that whole script
4) At the end of the script, you must reference the N/A Field correctly. You're not using the name you gave it--you're using the name I gave it so it can't find it.
NumNA = notAvailable //Either rename the NA field to NumNA or change the script but putting the field name you're using
5) Finally, I don't remember coming accross this before, but the script needs to have the last 2 lines switched. It seems to matter.
///////////////////////////////
var available = 0
var notAvailable = 0
for i = 0 upto 6 do
if(DDLday[i] > "0")then //square brackets
available = available + 1
continue
else
notAvailable = notAvailable + 1
continue
endif
endfor
NumNA = notAvailable //NumNA is the other field
$ = available // this must be the last line
/////////////////////////////////////
So, 2 of the problems were my fault.
That should do it.
Stephen
Views
Replies
Total Likes
https://acrobat.com/#d=5535SwVDbJHyVn81LUS18A
Hi Stephen, It is work first but When I have to change a item in a DDL the available and N/A days are not correct!
Thanks for all your help!
Views
Replies
Total Likes
Hi,
A couple of things--I should have mentioned the 8 DDLs before.
1) You have 8 DDLday--the script only loops through the first 7: (DDLday[0] thru DDLday[6]). Either delete the 8th DDLday or change the script to:
for i = 0 upto 7 do
2) You have a variable and a field with the same name: "available"--that's a problem. Me? I would change the "available" field to NumAvail. It is a good practice to name your fields using the type of field as part of the name--like you did with the DDLs. This helps you tell variables apart from the fields.
So, the 2 Fields can be NumNA and NumAvail
Otherwise, if you don't change the field name, you need to change the variable name.
That should fix it.
Stephen
Views
Replies
Total Likes
Stephen, It's work fine now!
Thank you for let me learn....
Have a great year!
Views
Replies
Total Likes
Views
Likes
Replies