Copy link to clipboard
Copied
Dear,
i have Three questions.
A)
When we use the switch and case , it's possible to put mores arguments on the case ?
exple : case "A" & "B" or case "A" || "B"
i'm asking because for exple, A=not good and is i choose it, the script can't enable one textfiel, and B=good can enable the textField.
B)
I have a dropdown and the value displayed will depend on the choice of checkbox or radio button.
I have two buttons: yes and no.
if I check Yes, the value in the dropdown or (Text flield) should be, for example, "validated" with a green background.
if I check No, the value in the dropdown or (Text flield) should be, for example, "Rejected" with a Red background.
by default, the two checkboxes or radio buttons are not activated and the dropdown or (Text flield) must remain hidden.
I don't know how to manage this.
C)
when saving the document as a pdf, how do you ensure that the imported images are not too compressed? because after printing, the quality is not at all good
Thank you in advance and happy new year to all.
Copy link to clipboard
Copied
A)
To use multiple cases in a switch statement, do it like this:
case "A":
case "B":
this.getField("A").value = "Good";
break;
If you want to add multiple statements to one 'case', you can do it like this:
case "A":
this.getField("A").value = "Good";
this.getField("B").value = "Not Good";
break;
B)
Let's say you have radio buttons named "Group1" with choices "Yes" and "No", you can use this as custom calculation script of text field where you want to show value/change color/hide:
var rb = this.getField("Group1").valueAsString;
if(rb === "Yes"){
event.target.display = display.visible;
event.value = "Validated";
event.target.fillColor = color.green;}
else if(rb === "No"){
event.target.display = display.visible;
event.value = "Rejected";
event.target.fillColor = color.red;}
else {
event.target.display = display.hidden;}
Copy link to clipboard
Copied
A) Please read the Core JS documentation. Arguments for the "case" statement must be a constant. If you need something more complicated, use an "if" statement.
B) Why a dropdown? doesn't seem necessary.
C) There's nothing you can do about importing images. Since Acrobat 10 or 11 the import has been crap.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
thank you @Thom Parker for taking the time to reply.
it helped me understand other mistakes I was making.
Copy link to clipboard
Copied
A)
To use multiple cases in a switch statement, do it like this:
case "A":
case "B":
this.getField("A").value = "Good";
break;
If you want to add multiple statements to one 'case', you can do it like this:
case "A":
this.getField("A").value = "Good";
this.getField("B").value = "Not Good";
break;
B)
Let's say you have radio buttons named "Group1" with choices "Yes" and "No", you can use this as custom calculation script of text field where you want to show value/change color/hide:
var rb = this.getField("Group1").valueAsString;
if(rb === "Yes"){
event.target.display = display.visible;
event.value = "Validated";
event.target.fillColor = color.green;}
else if(rb === "No"){
event.target.display = display.visible;
event.value = "Rejected";
event.target.fillColor = color.red;}
else {
event.target.display = display.hidden;}
Copy link to clipboard
Copied
Thanks @Nesa Nurani ,
your second case solved my problem.
and your answer to question B works perfectly.
thanks again for the help
Copy link to clipboard
Copied
C)
Try these settings but it depends on the method used because importing an image can be done in several ways.
"There are no settings that can be edited in …" means that images in this format are not recompressed and remain intact.