/ Id-Extras Forum / FormMaker Pro – Combo Box Export Values

  • Author
  • #6162 Reply
    Ryan G

    This is more of an InDesign issue, as it does not support adding export values for the list item entries within an combo box. I don’t see any functionality within FormMaker that compensates for this.

    Currently I would still have to edit the PDF form within Acrobat to enter values for each drop down item every time I export the PDF.

    Does anyone know of a script that I could embed in actions for each combo box that would just automatically populate the values (or entries and values) as soon as the box was accessed?

    I don’t know enough JS to create from scratch, but can tweak code that is close. I haven’t found anything like this in my search yet.

    Thanks for your thoughts



    Testing out FormMaker and so far this has been exactly what I have been searching for!

    #6290 Reply
    ~~Ariel~~
    Participant

    Hi Ryan,
    Excellent question!
    You’re right that this is an InDesign omission. But then, when it comes to forms, InDesign is very weak, which is exactly what FormMaker is there to help with.
    As you have found, there is no direct way of adding values to combo box items even with FormMaker.
    But there’s an excellent workaround which I will describe, which I think you’ll find is actually almost as easy.
    The trick is to use FormMaker to add a “document” Javascript to the form. Document scripts are run whenever the form is opened in Acrobat Reader.
    But even better for our purposes, document Javascripts are run when you run the FormMaker command on the form in Acrobat. Which is something you have to do anyway.
    So, what we’re going to do is to write a document Javascript that will populate ALL your combo boxes with both item names and their corresponding values. This is very easy to do, and I’ll give an example further down.
    Once you’ve added this document script in InDesign, it will be there forever (for that document) so you need only do this once (of course, you can modify it as needed if changes need to be made to the form.)
    You will then export to interactive PDF as usual and run the FormMaker command as usual. Doing so will invoke the document Javascript, and you’ll find that all the combo boxes are populated as needed.
    Now you can save the PDF and distribute it to end users.
    In fact, before saving the PDF, you might want to take one extra step – to delete the (now unneeded) document Javascript from the PDF. There’s no reason to distribute the PDF with that doc script included, since we are the ones who needed it, not the end user. (The combo boxes are already populated with items and their values, and that’s all the doc script is needed for.)

    Here’s a sample Javascript that you can tweak to add items and values to combo boxes. You might even find that it’s easier to add the items this way than to use InDesign’s slightly clunky user interface for adding one item at a time.
    The script assumes that you have an InDesign document open with 2 combo boxes in it, called “Combo Box 1” and “Combo Box 2”.

    Code:

    c = this.getField("Combo Box 1");
    c.setItems([["California", "CA"], ["Massachusetts", "MA"], ["Arizona", "AZ"]]);
    c = this.getField("Combo Box 2");
    c.setItems([["Apples", "100"], ["Pears", "200"], ["Oranges", "300"]]);

    The basic idea should be clear: We’re using the “setItems” command to add items and their values to each combo box. The items and their values are provided as a set of small 2-element arrays inside one larger array.

    I’m also attaching a PDF that shows the end result. This PDF includes the document Javascript, although, as mentioned, it makes more sense to delete it from the PDF before saving and distributing it.

    Hope that helps! If anything is unclear or if you have any other questions, post back.

    Thanks,
    Ariel

    • This reply was modified 7 months, 3 weeks ago by ~~Ariel~~.
    #6291 Reply
    Ryan G

    This is excellent!

    I was able to do some testing with it Friday and will do some further reviewing this week.

    -Ryan

    #6292 Reply
    ~~Ariel~~
    Participant

    Great, I think it’s a pretty workable solution! If you find any issues, please post back.

    Thanks,
    Ariel

Viewing 4 posts - 1 through 4 (of 4 total)

Tagged: 

Reply To: FormMaker Pro – Combo Box Export Values
Your information: