Highlighted

Help request

Community Beginner ,
Jul 16, 2020

Copy link to clipboard

Copied

Is it allowed to ask some help?

I am a beginner in .pdf programming and can't solve some issues.
1) On a page I have 20 textfields named Output_01, Output_02 etc. and 1 textfield named TotalOutput.
The output_01.. fields al display the word 'Juist' or 'Fout'.
In the textfield TotalOutput I want to see how many times the word 'Juist' is displayed in the textfields
Output_01 untill Output_20. The outcom must /2, so there will be displayed just a figure between 0 and 10.
Any help?

Topics

PDF forms

Views

104

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Help request

Community Beginner ,
Jul 16, 2020

Copy link to clipboard

Copied

Is it allowed to ask some help?

I am a beginner in .pdf programming and can't solve some issues.
1) On a page I have 20 textfields named Output_01, Output_02 etc. and 1 textfield named TotalOutput.
The output_01.. fields al display the word 'Juist' or 'Fout'.
In the textfield TotalOutput I want to see how many times the word 'Juist' is displayed in the textfields
Output_01 untill Output_20. The outcom must /2, so there will be displayed just a figure between 0 and 10.
Any help?

Topics

PDF forms

Views

105

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jul 16, 2020

Copy link to clipboard

Copied

Do you know any Acrobat JavaScript?  Have you tried writing your own script? You mentioned about that you can't solve some issues. 

 

What have you tried?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 18, 2020

Copy link to clipboard

Copied

Well I made 20 questions with each question a choicebox.
I made 1 page with a tabel in wich you see which choice you made at every question

and that choice is 'translated' to 'good' or 'wrong' in that table. So far I could program this.
I also programmed that on mousemovement the right answer with explanation shows up.

Now I need to calculate the in those output boxes mentioned time of the word 'good' / 2
this box needs to display a figure.
Later I want another textbox wich colors green if that figure is 7 or > with the text 'Congrats'
or color red if he figure is <7 with text 'Sorry, you failed'

Sorry for my bad English

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jul 17, 2020

Copy link to clipboard

Copied

You can use this code as the custom calculation script of your total field:

 

var counter = 0;
for (var i=1; i<=20; i++) {
	var fname = (i<10) ? "Output_0"+i : "Output_"+i;
	var f = this.getField(fname);
	if (f.valueAsString=="Juist") counter++;
}
event.value = counter/2;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 17, 2020

Copy link to clipboard

Copied

Thanks so far,
I wasn't able to try and test the given solutions, but am greatfull you all try to help me  with this.
I hope that I can try next monday and will display the results.
Thanks all!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 18, 2020

Copy link to clipboard

Copied

Hi try 67,

Tried it, but get a syntax error: invalid increment operand
2: on line 3

var fname = (i<10) ? "Output_0"+i : "Output_"+i;

Do I have to specify here all Output_ 01 - 20?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jul 18, 2020

Copy link to clipboard

Copied

There are no syntax errors in the code I sent. Did you edit it in any way?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 18, 2020

Copy link to clipboard

Copied

Oeps, I think I didn't do that............ (also difficult for me).

I now edit like this:
var counter = 0;
for (var i=1; i<=20; 1++ {
var Output_01 = (i<10) ? "Output_01"+i : "Output_"+i;
var f = this.getfield (TotalOutputFld)
if (f.valueAsString=="Juist") counter++;
}
event.value = counter/2;

but still has that syntax error.
The textfields that needs to be calculated are named Output_01, Outpud_02, Output_03 until Output_20
Something I must do wrong 😉

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Jul 18, 2020

Copy link to clipboard

Copied

1++ is not possible

Why have you changed i++ to 1++ ?

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jul 18, 2020

Copy link to clipboard

Copied

Why did you change the code I gave you? It should be used as-is.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 18, 2020

Copy link to clipboard

Copied

Oeps,

I am sorry. I thought you meant I had to edit it.

Will reset it tomorrow and change the mistake I typed 1++ to i++.
Will let you know!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Jul 18, 2020

Copy link to clipboard

Copied

You don't need type the code. You can copy and paste the code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 18, 2020

Copy link to clipboard

Copied

if working on the same computer it would be easy, yes 😉

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 18, 2020

Copy link to clipboard

Copied

Hi try67,

Many many thanks for your help. I was looking quit a time for this code: it works fine!
Can I ask another question please?

In textfield [txtResult_1] I like to display 'Congrats, you passed' if the figure I get with your code in the
textfield [TotalFld.value] is >7 (equal or higer to 7), the field may color green as well.
If the figure is <7 I like to display 'Sorry, you failed', the field may color red than.

Can you please help me with that code as well?

Many, many thanks for all!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jul 19, 2020

Copy link to clipboard

Copied

You can do that by adding this to the end of the current code:

 


var f = this.getField("txtResult_1");
if (event.value>=7) {
f.fillColor = color.green;
f.value = "Congrats, you passed";
} else {
f.fillColor = color.red;
f.value = "Sorry, you failed";
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 19, 2020

Copy link to clipboard

Copied

Hi try67,
thanks for all the help so far. Lot of hings work now at least, due to yoyr help: great!

Your last code is not listening to me, so what do I do wrong"
var f = this.getField("txtResult_1");
if (event.value>=7) {
f.fillColor = color.green;
f.value = "Gefeliciteerd, je bent geslaagd";
} else {
f.fillColor = color.red;
f.value = "Helaas, je bent niet geslaagd";
}
The only thing I edit is the text from English to Dutch.

I placed the code here:

 

Schermafbeelding 2020-07-19 om 16.18.10.png

 

 

Schermafbeelding 2020-07-19 om 16.22.22.png

15 is total 'Juist"

'8' is "Total_Juist' /2
In TxtResult_1 we should read now: 'Gefeliciteerd, u bent geslaags' Figure is 7 and the field should be green. The text displayed belongs to a figure < 7 and the field should be red.
The field shows up in blue, if I selct it with the mouse, it turns red.

What do i do wrong?

Thanks for your help again

With kind regards,

 

 

 

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 19, 2020

Copy link to clipboard

Copied

Forgot this 1:

Schermafbeelding 2020-07-19 om 15.59.57.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jul 19, 2020

Copy link to clipboard

Copied

You were supposed to add the new code after the old one, not replace it.

And turn off the Fields Highlighting to make the fill color visible.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 19, 2020

Copy link to clipboard

Copied

Ok, thanks, but don't get that, sorry.
The textbox that has to display the text and color is an new textbox, was there already a code in it?
May be I think to analogue?

May be ebst to do is delete textfield [Textresult_1] and make a brand new textfield?
I tried to delete the fielss highlightning, but that didn't respond.

Another thing: [TotalFld.value] is [TotalJuist] /2. It now displays 15 good is figure 8. Officially it's
7.5, but I would down that to 7, not up it to 8. Is that difficult to manage?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 20, 2020

Copy link to clipboard

Copied

OK try67,

Forget my last post. Understand now what you meant. The code to display in TxtResult_1 has to be written in
TotalFld.value, wow. Thanks so far it is working, except the coloring. Will check that in reader instead of DC.

Is there a code after event.value = counter/2; that counts downwards wenn the figure is x,5, so 6,5 is 6 not 7 etc?  I now see a total "Juist" of 13, which displays the figure 7 (and the output text is "Sory, you failed"
which is correct, but should be with the figure 7 "Congrats, You passed").

Well it's amazing how far you helped me, thanks a lot!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jul 20, 2020

Copy link to clipboard

Copied

Change:

event.value = counter/2;

To:

event.value = Math.floor(counter/2);

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 20, 2020

Copy link to clipboard

Copied

Thanks 4all try67,

All these codes I couldn't find or couldn't understand.
Only coloring doesn't work, only after I touch the field with the mouse.

In the Text field properties under appearance I didn't fill any color to fill the field with. I see the color is filled red (occasionally green). I only gave a color for the text.
Any thoughts?
Again many thanks for willing to help!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 20, 2020

Copy link to clipboard

Copied

After I checked the box read only on the tab general on text field properties, it works very very good!
So I thnik my ' problems' are solved.
many many thanks4all!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Resources
One Stop Solution for Acrobat
Edit a PDF