Copy link to clipboard
Copied
Below is the code I wrote for PDF form. I do not want a line of text to appear unless IF statement is false.
var a = Number(this.getField("A").value);
var b = Number(this.getField("1").value);
if (b==0) event.value = "";
else event.value = "1 CARTON OF",(a%b);
I want the end result to be either blank or "1 carton of " (calculated number).
Is this possible?
Copy link to clipboard
Copied
Yes. Change the last line of your code to:
else event.value = "1 CARTON OF" + (a/b);
Copy link to clipboard
Copied
Yes. Change the last line of your code to:
else event.value = "1 CARTON OF" + (a/b);
Copy link to clipboard
Copied
Almost there...thank you. That number is supposed to be a remainder of total number of pieces divided by the quantity per carton. It is designed to give me a partial carton quantity on a packing list.
Copy link to clipboard
Copied
In that case use the modulus operator ("%"), which you originally had. I changed it to the division operator ("/") because I had assumed (incorrectly) that that's what you mean to calculate.
Copy link to clipboard
Copied
Glad I could find an expert at this.
I now have a dropdown menu of various ship to locations. I want to have the full address appear in another text box on my form when a certain location is selected from the menu.
Ideas?
Copy link to clipboard
Copied
To learn how to do that you should read this tutorial:
https://acrobatusers.com/tutorials/change_another_field
Or you can use this tool I've developed, exactly for this task:
Custom-made Adobe Scripts: Acrobat -- Populate Fields From Dropdown
Copy link to clipboard
Copied
I feel I am almost there. Getting an syntax error that I am missing a ":" after property id 2: at line 3.
// Place all prepopulation data into a single data structure
var DeptData = { 6540 STONEGATE:{ ADDRESS: "LUTRON ELECTRONICS 6540 STONEGATE ROAD ALLENTOWN PA 18106"},
6560 STONEGATE:{ ADDRESS: "LUTRON ELECTRONICS 6560 STONEGATE ROAD ALLENTOWN PA 18106"},
COOPERSBURG:{ ADDRESS: "LUTRON ELECTRONICS 7200 SUTER ROAD COOPERSBURG PA 18036"},
EL PASO:{ ADDRESS: "LUTRON C/O SPACE BORDER LOGISTICS 9560 JOE RODRIGUEZ DR. EL PASO TX 79927"},
PUERTO RICO:{ ADDRESS: "LUTRON SM INC. CARR #909 KM 0.2 INDUSTRIAL PARK MARIANA 2 HUMACAO PR 00792"}};
function SetFieldValues(cDeptName)
{
this.getField("ADDRESS").value = DeptData[cDeptName].ADDRESS;
}
Copy link to clipboard
Copied
You must put quotes around any text that contains a space, and you should
probably do it in all cases anyway.
On Tue, Feb 14, 2017 at 4:27 PM, DKPrintConcepts <forums_noreply@adobe.com>
Copy link to clipboard
Copied
I don't understand. There ARE quotes where they should be.
Copy link to clipboard
Copied
No, there aren't. You need to put quotes around the names of each literal object as well, such as "6560 STONEGATE".
Copy link to clipboard
Copied
OH...gotcha. Almost there.
Obviously, these are ship to addresses. how can I put breaks in so the address appears like below?
LUTRON ELECTRONICS
6560 STONEGATE ROAD
ALLENTOWN, PA 18106
Again...thank you so much for your patience.
Copy link to clipboard
Copied
When you want to insert a line-break use this code "\n", like so:
LUTRON ELECTRONICS\n6560 STONEGATE ROAD\nALLENTOWN, PA 18106
And of course you need to set the field as Multiline.
Copy link to clipboard
Copied
AHHHHHHHHHHHHHHH...driving me crazy.
I added another item to the dropdown and now it won't work.
var SHIPTO = {{"SELECT SHIP TO ADDRESS":{ ADDRESS: " "},
"6540 STONEGATE":{ ADDRESS: "LUTRON ELECTRONICS\n6540 STONEGATE ROAD\nALLENTOWN, PA 18106"},
"6560 STONEGATE":{ ADDRESS: "LUTRON ELECTRONICS\n6560 STONEGATE ROAD\nALLENTOWN, PA 18106"},
"COOPERSBURG":{ ADDRESS: "LUTRON ELECTRONICS\n7200 SUTER ROAD\nCOOPERSBURG, PA 18036"},
"EL PASO":{ ADDRESS: "LUTRON C/O SPACE BORDER LOGISTICS\n9560 JOE RODRIGUEZ DR.\nEL PASO, TX 79927"},
"PUERTO RICO":{ ADDRESS: "LUTRON SM INC.\nCARR #909 KM 0.2\nINDUSTRIAL PARK MARIANA 2\nHUMACAO, PR 00792"}};
function SetFieldValues(cSHIPTO)
{
this.getField("ADDRESS").value = DeptData[cSHIPTO].ADDRESS;
}
Copy link to clipboard
Copied
There's a syntax error in your code. Drop one of the first opening curly brackets in the first line.
Copy link to clipboard
Copied
I tried that...still will not work. All selections return the same address.
Copy link to clipboard
Copied
Why did you change the variable name from DeptData to SHIPTO?
Copy link to clipboard
Copied
I don't know. I changed it back and it works. Genius!!! Thank you.
Copy link to clipboard
Copied
It WORKS!!!!!! Thank you for all your help.

