Copy link to clipboard
Copied
I have a form with several drop-downs fields. The values in the drop-down are "Please Select, F 1008, F 1009, F 1024, F 1173, F 1305,
F 1498, F 1573, Letter". For e.g, F 1008 is selected in a drop-down, the total value is 1. If F 1009 is selected in another drop-down. The total becomes 2. The count should run for all the values except for "Please Select". Is there a way to do this?
Copy link to clipboard
Copied
OK. In that case you can define this function as a doc-level script:
function countValues(v) {
var total = 0;
for (var i=1; i<=22; i++) {
if (this.getField("ddref"+i).valueAsString==v) total++;
}
event.value = total;
}
And then as the custom calculation script of one of your text fields you can enter this code, for example:
countValues("F 1008");
Copy link to clipboard
Copied
Yes, this can be done using a script.
What are the names of the drop-down fields?
Copy link to clipboard
Copied
Thank you for helping.
The names are: "ddref1","ddref2" ... to "ddref22"
Copy link to clipboard
Copied
OK. In that case you can define this function as a doc-level script:
function countValues(v) {
var total = 0;
for (var i=1; i<=22; i++) {
if (this.getField("ddref"+i).valueAsString==v) total++;
}
event.value = total;
}
And then as the custom calculation script of one of your text fields you can enter this code, for example:
countValues("F 1008");
Copy link to clipboard
Copied
Should i be adding as the document script?
Because i have other calculations in the form.
Copy link to clipboard
Copied
You can create multiple doc-level scripts. There's no conflict there, unless you use the same function names.
Copy link to clipboard
Copied
I'll try it and let you know if it works.. by the way.. i have other dropdown in the same form.. the drop down has values like "Please select", "Yes", "No".. The fields needs to count for the number of yes only..
The dropdowns' names are "ddcard1", "ddcard2" .... to "ddcard22".
Copy link to clipboard
Copied
You can easily convert the code I provided to do it... Just change the function name and the base field-name.
Copy link to clipboard
Copied
Thank you for helping.
It's working correctly.

