Copy link to clipboard
Copied
Hallo an alle,
brauche ein "bisschen" Hilfe
Wie kann ich mit Acrobat Pro DC (oder alternative Adobe LiveCycle Designer ES4) Textfelder addieren die ein bestimmten Textinhalt haben?
Bei einer anderen Textfeld reihe möchte ich Textfelder addieren die ein wert oder Text haben, wenn leer dann nicht zählen.
Ich weiß das dies mit Java möglich ist, als Laie weiß ich nur nicht wie
Danke für jede Hilfe im Voraus
Niko
It does not add up the fields with content text
var count = 0;
for (var i=10; i<=19; i++) {
if (this.getField(i).valueAsString != "") count++;
}
event.value = count;
Copy link to clipboard
Copied
Want you build the sum of fields or count the filled fields?
Info: Acrobat uses Javascript, not Java.
Copy link to clipboard
Copied
Hi Bernd Alheit,
I want to use Acrobat Pro DC to add text fields that have a specific text content (what ever can be this text).
With another text field row I want to add text fields that have a value or text, if empty then don't count.
Thx
Niko
Copy link to clipboard
Copied
You can use something like this:
var count = 0;
// for fields with specific text:
if (this.getField(" field name ").valueAsString == " specific text ") count++;
// for non-empty fields:
if (this.getField(" field name ").valueAsString != "") count++;
Copy link to clipboard
Copied
Thank you very much, great that it was so fast and accurate.
Could scream with joy
My last question, where is it inserted?
Text field properties in calculation or validation?
...or better, where and how exactly is this inserted?
Thx
Niko
Copy link to clipboard
Copied
At the calculation of the field where you want display the result.
At the end add the line:
event.value = count;
Copy link to clipboard
Copied
Thanks again for your help.
It's really a big help for me.
I'll use it tomorrow, when I'm back in the office.
Since I found this forum, I start to see some light in my Acrobat tunnel.
Copy link to clipboard
Copied
ll be at the office as soon as I can to try it out...I was determined to finish it today.
var count = 0;
if (this.getField(" field name ").valueAsString != "") count++;
event.value = count;
It works, but I don't know how to add all Text boxes (fields) i want.
The script is only for one text box, but wants to add several text boxes together if it is content.
How do I add several text boxes together if they are not empty?
sorry if I get on my nerves and thanks again in advance
Niko
Copy link to clipboard
Copied
If I may add an example.
I want to count Text Box 10 to 19 if Text Box has content, if no content doesn't count then.
Copy link to clipboard
Copied
You can use something like this:
var count = 0;
for (var i=10; i<=19; i++) {
if (this.getField("Text Box"+i).valueAsString != "") count++;
}
event.value = count;
Copy link to clipboard
Copied
I'm doing something wrong.
I have text fields named "10" to "19", I copied the script, but it doesn't work.
var count = 0;
for (var i=10; i<=19; i++) {
if (this.getField("10"+i).valueAsString != "") count++;
}
event.value = count;
where do I make the mistake?
Copy link to clipboard
Copied
Change:
getField("10"+i)
To:
getField(i)
Copy link to clipboard
Copied
It does not add up the fields with content text
var count = 0;
for (var i=10; i<=19; i++) {
if (this.getField(i).valueAsString != "") count++;
}
event.value = count;
Copy link to clipboard
Copied
No, it just counts how many fields have a value that isn't empty.
Do you want to add their actual values, ie sum them up?
Copy link to clipboard
Copied
i want to count all fields from 10 to 19 that have a value/text, the empty fields do not count.
The second script should count fields from 20 to 29 that have a certain text.
Copy link to clipboard
Copied
sorry if i don't express myself correctly, but my english is not the best
Copy link to clipboard
Copied
i want to count all fields from 10 to 19 that have a value/text, the empty fields do not count.
The script in my last post will do that.
The second script should count fields from 20 to 29 that have a certain text.
Alongside the 10-19 fields, or separately?
sorry if i don't express myself correctly, but my english is not the best
Your English is fine.
Copy link to clipboard
Copied
The script in my last post will do that.
i use this script and not works
Alongside the 10-19 fields, or separately?
separately
Copy link to clipboard
Copied
Probably or rather, I'm making a mistake somewhere.
however, it's depressing, will continue tomorrow...thank you for your time and effort.
Any additional help is still welcome.
Thx
Niko
Copy link to clipboard
Copied
Check the console for errors.
Copy link to clipboard
Copied
This is not the script from my last post...Take the code from your reply #14.
If it's not working there's probably an error. You should check the JS Console.
Copy link to clipboard
Copied
Thx again all for your Help...now i solve the problem
Must've slept in to get the hang of it.
All well, thank you it was really a big help.
Wishes all a good and happy day, may everything work out
Copy link to clipboard
Copied
One last
Try to count the sum of the fields with certain text "E" together, without success.
-------------------------------------
var count = 0;
for (var i=10; i<=19; i++) {
if (this.getField(i).valueAsString != "E") count++;
}
event.value = count;
-------------------------------------------
What am I doing wrong in the script?
Thx
Niko
Copy link to clipboard
Copied
You're using the wrong opearator. "!=" means NOT EQUALS. You should be using "==", which is the EQUALS comparison operator in JS.
Copy link to clipboard
Copied
You're not human... you're an angel
Thank you, now it has sparked
Have a nice day
Niko