Highlighted

Need some help for a .pdf

Community Beginner ,
Jul 20, 2020

Copy link to clipboard

Copied

In a .pdf  I created a choce textfield [Choice_01]. You can make choices for about 25 items.
I like to display you a description on your choice in a textfield I called [Output_01].

So for every choice I have another discrition.
Can you please provide me the script to programm my wish?
Thank you.

TOPICS
Create PDFs, PDF forms

Views

63

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

Need some help for a .pdf

Community Beginner ,
Jul 20, 2020

Copy link to clipboard

Copied

In a .pdf  I created a choce textfield [Choice_01]. You can make choices for about 25 items.
I like to display you a description on your choice in a textfield I called [Output_01].

So for every choice I have another discrition.
Can you please provide me the script to programm my wish?
Thank you.

TOPICS
Create PDFs, PDF forms

Views

64

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
Jul 20, 2020 0
Most Valuable Participant ,
Jul 20, 2020

Copy link to clipboard

Copied

As the custom calculation script of Output_01 enter something like this:

var cChoice = this.getField("Choice_01").valueAsString;

if (cChoice=="Item 1") event.value = "Description for Item 1";

else if (cChoice=="Item 2") event.value = "Description for Item 2"; // etc.

else event.value = "";

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...
Jul 20, 2020 0
Community Beginner ,
Jul 21, 2020

Copy link to clipboard

Copied

Hi try67,

Thank you again for the help, it works direct fine!

Because most descriptions have at least 5 lines I think the code will be very long and editting text
can be complecated? An easy way (I think) is to place these text in textfields which I call [Description for Item 1] //etc.
Those textfields I will place hidden on page 2.
Can you provide me the code for this option, please?
If you have a better option, feel free to advise.

Thanks!

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...
Jul 21, 2020 0
Most Valuable Participant ,
Jul 21, 2020

Copy link to clipboard

Copied

I don't see the issue with having multiple lines... But if you prefer to create separate fields for each description, that's possible too. In that case you'd probably just want to show/hide them, which you can do like this:

 

var cChoice = this.getField("Choice_01").valueAsString;
this.getField("Description for Item 1").display = (cChoice=="Item 1") ? display.visible : display.hidden;
this.getField("Description for Item 2").display = (cChoice=="Item 2") ? display.visible : display.hidden; // etc.

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...
Jul 21, 2020 0
Most Valuable Participant ,
Jul 21, 2020

Copy link to clipboard

Copied

Actually, if you place the code as the custom Validation script of Choice_01 change the first line to:

var cChoice = event.value;

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...
Jul 21, 2020 0
Community Beginner ,
Jul 21, 2020

Copy link to clipboard

Copied

Hi try 67
I tried to place the wanted text in the code, but because I like to text like this:
- yes

- No

- May be

- Go for it
In the code I see it's not allowed and a failluere is given. Ik don;t know how to solve this, sorry.
So for more reasons I think it is ok to use different textfields wich displays if that Item-nr has been choosen?
I can place those textfields on page 2 an visually hide them, but let them pop up if wanted?

If I know how I can type on in the code, it may be is easy as it 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...
Jul 21, 2020 0
Most Valuable Participant ,
Jul 21, 2020

Copy link to clipboard

Copied

I answered both questions already. See above.

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...
Jul 21, 2020 0
Community Beginner ,
Jul 21, 2020

Copy link to clipboard

Copied

Thanks again try67,
To display that seperate textfield is not working for me, I can't get that code working, sory.
So I will put the text I want into the code. But, I was using bullets and gave a enter in the textline, but
I get faillures on that.
Is it not allowed to enter  (or shift enter) or do I need a code?

Accepted is: - Hello, - Goodbye, - See you, - Ciao

Not accepted is:
- Hello,
- Goodbye,
- See you,
- Ciao

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...
Jul 21, 2020 0
Most Valuable Participant ,
Jul 21, 2020

Copy link to clipboard

Copied

Use "\n" to insert a line-break in a string.

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...
Jul 21, 2020 0
Community Beginner ,
Jul 22, 2020

Copy link to clipboard

Copied

Hi try67,
thanks so far. \n works fine!

At this moment I choosed your option to write te outputtext in the code, so no seperated textfield.

Is it possible to have 2 choicefields which displays the same text in Output_01?
I can give fi the same exportvalue like 'Item 01', 'Item 02' etc.

The code you supplied for the Output_01 textfield is:
var cChoice = this.getField("Choice_01").valueAsString; //etc. etc.
(How) Can I write "Choice_00", next to "Choice_01" so the same text is displayed
and is it possible to disable 1 of the Choicefields if the other is used?
this.getField("Description for Item 2").display = (cChoice=="Item 2") ? display.visible : display.hidden; // etc.

If working with seperated textfield for this option is a better or easier alternatvie, I will use that option/

Thanks for the 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...
Jul 22, 2020 0
Most Valuable Participant ,
Jul 23, 2020

Copy link to clipboard

Copied

I'm sorry, I don't quite follow what you mean... Do you want to make it dependent on two fields?

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...
Jul 23, 2020 0
Community Beginner ,
Jul 23, 2020

Copy link to clipboard

Copied

Well,

I have 2 choice-fields [choice_00] and [Choice_01]

The choice you make in eather on of them should display the same text in [Output_01].

Visualisation:
In [Choice_00] i can choose for try67. [Choise_00] is filled with abbr. and shortkeys

in [Choice_01) i can choose for your full name [Choice_01] is filled with full names.

I will give the same exportvalue at try67 as on your full name.
The displayed text in Output_01 must be same whenever I chose try67 or your full name.
Problem can be that if I made in both [Choice_00] and [Choice_01] choices with different exportvalues,
the textfield Output_01 will get nuts? for instance I choose your abbr try67, but my fullname.
Both have diff exportvalues.
So I was thinking, can I place in this string:
var cChoice = this.getField("Choice_01").valueAsString;  as well textfield [choice_00], like
var cChoice = this.getField("Choice_00" and "Choice01").valueAsString;
so that [output_01] will display the exportvalue of [choice_00] or the exportvalue of [Choice_01]
and if so, how can block the use of the choicefield that not is used?

Hope it's more understandable like this?

 

 

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...
Jul 23, 2020 0
Most Valuable Participant ,
Jul 23, 2020

Copy link to clipboard

Copied

So you want a single variable to combine the values of both fields?

If so, you can do it like this:

var cChoice = this.getField("Choice_00").valueAsString + this.getField("Choice_01").valueAsString;

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...
Jul 23, 2020 0
Community Beginner ,
Jul 24, 2020

Copy link to clipboard

Copied

Sorry try67,
It's not combine, it's both choices to display the same. Users must have the oportunity to make a choice in [Choose_00] or in [Choose_01]. Eigther the field they choose to use, the output will be the same.

But if they make a choice in [Choose_00] it must not be possible to make a choice in [Choose_01]
(and viceversa).
Hope I made it more clear like this?

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...
Jul 24, 2020 0
Community Beginner ,
Jul 26, 2020

Copy link to clipboard

Copied

Besides the above question (not combine but display same output on diff. choicefield) there's an new issue
I can't solve. Can  you please explain what I do wrong in next script?

There 3 kind of outputs
- 1 - 5 with output: "Hey I like your text"
   (field gray, text white

- 6 -14 with output: :Sorry, don't like your answer"

- other values with no output
  Now I like the field transparent

 

var f = this.getField("Output_16");
if (cchoice=="1”,"2”,”3”,"4”,"5") {
f.fillColor = color.gray;
f.textColor = color.white;
f.value = "Hey, I like your answer";} 
else if (cchoice==“6”,"7”,"8”,"9”,"10","11”,"12”,"13”,"14”) {
f.fillColor = color.gray;
f.textColor = color.white;
f.value = "Sorry, don't like your answer";}
else if (choice==""){
f.fillColor = color.transparent;
}
cchoice field is named [Choice_05]

Thanks for the 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...
Jul 26, 2020 0
Adobe Community Professional ,
Jul 26, 2020

Copy link to clipboard

Copied

A comparison, i.e., "==" only applies to a single value. There is no syntax in the JavaScript language for stacking up comparison values in a comma separated list.  I wold highly suggest you refer to the Core JavaScript reference at either Mozilla(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference) or W3Schools(https://www.w3schools.com/js/default.asp). Take a few of the tutorials. Guessing at a language syntax is unproductive. 

 

To that end, since the exports from the list field are numbers, you can use a numerical comparison. 

here's some code to help you along.

 

var nChoice = Number(cchoice);

if(nChoice < 6)

{

 ....  

f.value = "Sorry, don't like your answer";} 

....

}

else if( nChoice < 15)

{

 ....  

f.value = "Hey, I like your answer";} 

....

}

 else

f.fillColor = color.transparent;

 

 

 

 

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...
Jul 26, 2020 0
Community Beginner ,
Jul 26, 2020

Copy link to clipboard

Copied

Hi Thom,
In that case I have to explain that the part of the code did work.
I used instead of //if (cchoice=="1”,"2”,”3”,"4”,"5") {
this code (which it should be):
if (cchoice=="179”,"180”,”181”,"182”,"184") {

It's not that the text I want to have displayed won't work, it's more that the output_16 textfield

won't get color.tranparent.
So <6 won't work in my case or I have to change all values to 1, 2, 3,....

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...
Jul 26, 2020 0
Adobe Community Professional ,
Jul 26, 2020

Copy link to clipboard

Copied

So the "if" statement you've just posted has two fatal errors.

 

if (cchoice=="179”,"180”,”181”,"182”,"184") {

 

First, as I stated before, this is not a valid syntax for a comparison. It will always return true, because  the list operator ",", forces the execution of each item in the list. The last item in the list ("184") is the result of the "if" condition. In JavaScript, anything that is non-zero is interpreted as true. 

 

The second fatal error is the quotes. notice that some of them in your post look different. They are a little curly. These are  non-ASCII quotes and if you look in the console window you'll see that a syntax error is reported. 

 

So your code as written, absolutely will not work. 

 

Now, you've misspelled "color.transparent" in the post, but I'll assume that it's correct in the code. It's possible this color value is not defined. You can test this in the console window.

If this is the case, then use this code instead:

 

f.fillColor = ["T"];  

 

And a final note. If the values in the comparison are consecutive numbers, then you can use a numerical comparison. It will make the code more compact. 

 

 

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...
Jul 26, 2020 0
Community Beginner ,
Jul 27, 2020

Copy link to clipboard

Copied

Hi Thom,
Don't get it all, because of bad English, sorry (same with the url-courses).
The curly quotes aren't in the code. They're just written like this by mail.app.
I renemed the exportvalue from 1 - 15:
1-5 need a text in a gray textfield

6 - 14 need another text in a gray textfield
15 needs ["T"] and no text
With your help I created next code, which doesn't work: The outputfield ain't colored gray and there is no text output. because of //, this field doesn't know that the outputfeld is Output_16? Without// it's not working either.

//var f this.getField("Output_16");
var nChoice=Number(cChoice);
if (nChoice <6){
f.fillColor=color.gray;
f.value="I like your answer";}
else if (nChoice <15){
f.value="Sorry, don't like your answer";}
else {
f.fillColor = ["T"];
}
I do hope you will have a look at the code and advise me. Thanks for that.

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...
Jul 27, 2020 0
Adobe Community Professional ,
Jul 27, 2020

Copy link to clipboard

Copied

You have not provided enough information. What is the relationship between the output field and the list field?

On what event? and on what field is this code located? 

 

 

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...
Jul 27, 2020 0
Community Beginner ,
Jul 28, 2020

Copy link to clipboard

Copied

The question was this:
var f = this.getField("Output_16");
if (cchoice=="1”,"2”,”3”,"4”,"5") {
f.fillColor = color.gray;
f.textColor = color.white;
f.value = "Hey, I like your answer";}
else if (cchoice==“6”,"7”,"8”,"9”,"10","11”,"12”,"13”,"14”) {
f.fillColor = color.gray;
f.textColor = color.white;
f.value = "Sorry, don't like your answer";}
else if (choice==""){
f.fillColor = color.transparent;
}
cchoice field is named [Choice_05]

but this "1”,"2”,”3”,"4”,"5" is not poss you told. How do I solve this "1”,"2”,”3”,"4”,"5" so the outcome is equal for all exportvalues? Can I write that in 1 line in other notation or do I have to make new lines (and how is the code?

 

Thanks.

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...
Jul 28, 2020 0
Adobe Community Professional ,
Jul 28, 2020

Copy link to clipboard

Copied

The code you posted using "var nChoice=Number(cChoice);"  is correct, except for the "f" variable being commented out. Why is it commented out? If you would like helpful advice, then please answer the questions asked in this post and my previous one. 

 

 

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...
Jul 28, 2020 0
New Here ,
Jul 28, 2020

Copy link to clipboard

Copied

creat pdf

 

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...
Jul 28, 2020 0