Copy link to clipboard
Copied
Hi,
I work in a warehouse, and we are constantly making creating Bill of Ladings for our trucks.
We have a PDF template that we use currently with text boxes, and are more or less picking up and dropping off at the same 10-20 locations.
How can I make a pull down menu in the shipper section with a list of the usual suspects, that will generate the shippers address underneath, ditto for the consignee?
I'm understand from my research that this is a task for java script. Can someone walk me through this? Or maybe direct me to a video tutorial? I would love to understand what I'm doing and not just copying and pasting.
Thank you!
O.
Copy link to clipboard
Copied
You could use a custom Keystroke script for the dropdown, something like the following:
// Custom Keystroke script for combo box
(function () {
if (!event.willCommit) {
// Set up an array of addresses. \r = carriage return
var aAddr = [];
aAddr[0] = "1234 56th St. S.\rSeattle, CA 98104";
aAddr[1] = "5678 Industrial Blvd.\rDenver, CO 80123";
// Continue below with other addresses
// Get the export value of the selected item
var ex_val = event.changeEx;
// Get the corresponding address
var addr = aAddr[ex_val];
// Populate the multiline text field with the address
getField("Address").value = addr;
}
})();
The dropdown should be configure to "Commit selected value immediately". The corresponding multiline text field to display the address is assumed to be named "Address", so change to match whatever you're using. Also, you have to set the export value of the items to numbers, starting with 0 for the first item and incrementing by 1 for each subsequent item. So the export values of the items are the same as the corresponding array index of the address.
Copy link to clipboard
Copied
Is the address a single field (multiline) or several fields (address, city, state, zip, etc.) When you say "ditto for the cosignee", do you mean you will have another dropdown, or will it be based on selected shipper?
Copy link to clipboard
Copied
Thanks George for stepping in.
Yes. Address will be 3 lines. Top line will be a drop down with a name, second line street, 3rd city state zip. No need to break it into fields. Maybe 2 total, one pull down with a name, and that will populate an address directly underneath.
I'd like to do the exact same a second time, for the Consignee. A dropmenu with a name, followed by a field for the address.
I appreciate your help.
O.
Copy link to clipboard
Copied
You could use a custom Keystroke script for the dropdown, something like the following:
// Custom Keystroke script for combo box
(function () {
if (!event.willCommit) {
// Set up an array of addresses. \r = carriage return
var aAddr = [];
aAddr[0] = "1234 56th St. S.\rSeattle, CA 98104";
aAddr[1] = "5678 Industrial Blvd.\rDenver, CO 80123";
// Continue below with other addresses
// Get the export value of the selected item
var ex_val = event.changeEx;
// Get the corresponding address
var addr = aAddr[ex_val];
// Populate the multiline text field with the address
getField("Address").value = addr;
}
})();
The dropdown should be configure to "Commit selected value immediately". The corresponding multiline text field to display the address is assumed to be named "Address", so change to match whatever you're using. Also, you have to set the export value of the items to numbers, starting with 0 for the first item and incrementing by 1 for each subsequent item. So the export values of the items are the same as the corresponding array index of the address.
Copy link to clipboard
Copied
It works!
Thank you my friend, you made my day!
Thank you!
O.
Copy link to clipboard
Copied
hello!
I'm trying something similar though the problem is that the combo box populates the export value and not the item name.
any ideas on how to do this and get the item name instead of export value?
Copy link to clipboard
Copied
You can get this with the property currentValueIndices of the field and the method getItemAt.
Look at the example of currentValueIndices.
Copy link to clipboard
Copied
the code I'm using is:
(function () {
if (!event.willCommit) {
var aPrice = [];
aPrice[0] = "5 ";
aPrice[1] = "10 ";
aPrice[2] = "20 ";
var aIndex = [];
aIndex[0] = 0;
aIndex[1] = 1;
aIndex[2] = 2;
var ex_val = event.changeEx;
var price = aPrice[aIndex[ex_val]];
getField("amount").value = price;
}
})();
How can I intergrade this?
Copy link to clipboard
Copied
Where does you use this script?
Copy link to clipboard
Copied
this is keystroke script I use in a combo box of "services" that turns to a text box of amounts.
For example:
aItem[1] = "SINGLE "
aIndex[1] = 1
aPrice[1] = "35 "
By selecting the "single" in the combo box, the outcome in the text box is the price assigned (for this selection the outcome is 35€ as seen below)
The problem is that once I move to another field, the combo box changes from "single" to "1"
eg. what I get:
what I want:
Copy link to clipboard
Copied
Where does you use array aItem?
Copy link to clipboard
Copied
sorry i was trying to make this general example
here is the full code:
// Custom Keystroke script for combo box
(function () {
if (!event.willCommit) {
var aAddr = [];
aAddr[0] = "0 ";
aAddr[1] = "35 ";
aAddr[2] = "80 ";
aAddr[3] = "165 ";
aAddr[4] = "250 ";
aAddr[5] = " ";
aAddr[6] = "110 ";
var aIndex = [];
aIndex[0] = 0;
aIndex[1] = 1;
aIndex[2] = 2;
aIndex[3] = 3;
aIndex[4] = 4;
aIndex[5] = 5;
aIndex[6] = 6;
var ex_val = event.changeEx;
var addr = aAddr[aIndex[ex_val]];
getField("amount1").value = addr;
}
})();
Copy link to clipboard
Copied
Again. Where does you use array aItem?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You have post following:
aItem[1] = "SINGLE "
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
There is a example in the Acrobat Javascript Reference.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Search the web for the Reference.
Copy link to clipboard
Copied

