Can I import the data from a column in a tab denim file and use it to populate the items in a dropdown/combo box, loading on document open?
Hello experienced JSers.
I'm starting to get to grips with a bit of Javascript knowledge, from being a total fresher a couple of weeks ago. Now that my eyes have been opened to to what is possible, I want to be able to utilise what I've learnt as much as I can.
I have a fillable form, created with Acrobat Pro DC and it contains a lot of fields for customer info (first name, last name, three address fields, telephone number, and email address, etc). One of them is simply called "Company", and is for the company name that the customer works for.
I have set up a dropdown list/combo box for Company, and I've got it linked to a tab delimited .txt file, using a folder-level script as follows:
var Trusted_importAddress = app.trustedFunction(importAddress);
function importAddress()
{
app.beginPriv();
var cCoNoforImport = this.getField("Company").value;
this.importTextData("/**FULLFILEPATH**/**FILENAME**.txt", cCoNoforImport);
app.endPriv();
}
The script is being called by the following code, onBlur from the actions section of the dropdown box's properties.
Trusted_importAddress(this);
At the moment, it is all working well, and on the selection from the user of the item in the Company dropdown, the form fills in all the relevant fields on the rest of the form, using the data from the .txt file.
Great.
The thing is, I have had to manually specify all the company names and add the export values as the row numbers in the text file, putting them all into the options section of the box's properties one by one.
What I'm looking for is this:
When the form file loads in acrobat, I want it to import the data from the Company column in the .txt file, and automatically populate the Company Dropdown box with all of the items in that column. (Then, selecting the company name in the drop down will still populate th eother fields with the relevant data, as happens now.)
There are a couple of other requirements, but I'll be happy with the above for now, and the rest can come later, but if anyone can help with combining the above with the below, I'll be over the moon:
In an ideal world, I would like the ability to be able to type in entries for a customer whose details are not in my .txt file. That's not an issue, but It would be amazing if once the details had been filled in on the form, the form could have a button (or a custom menu item, based on security requirements) that could get the data that I have entered into the form, and put it into the .txt file, as a new line, saving the txt file with the new customer for future use.
Whether that would require getting the entire txt file as a massive array, and adding the new data to the end, then saving it as a new file but with the same name, so that it overwrites the old one, or whether the new info can be appended to the end of the existing file, and saved that way, I'm not sure.
If anyone reading this is able to help with any part of this rather large reques, I will be eternally grateful. Ireally appreciate the time and effort of anyone who trues to help on forums like this, whether or not I am abe to mak theur suggestions work in practice.
Thanks in advance for your time.
Nathan
