3 Replies Latest reply on Oct 18, 2017 12:26 AM by bcs marketing

    Set multiple fields to certain format

    bcs marketing Level 1

      I have a PDF form that's gone awry; some check boxes turn black when printing, while others don't and there's no clear reason for this. Worse is that those black check boxes are completely black regardless of whether they're checked or not, so there's no telling whether they're actually checked.

       

      I've saved the scripts from the "All JavaScripts" option of the form, as the scripts work great, and now I want to load those into a new export (from InDesign) of the form. Unfortunately that doesn't work; none of the scripts seem to save in the new form. I'm guessing it's because they can't be bound to the proper fields due to them not having the correct formatting set yet.

       

      All fields are named logically as in "quantity-[product]" and "net-price-[product]", so I'm thinking it should be possible to run a JavaScript once (using an action set to a button press?) to set all fields whose names start with a certain string ("net-price" for example) to a certain format. Now that brings me to my problem: I can't get the sample scripts found online to work at all.

       

      var theField = getField(getNthFieldName(fieldNumber));

      for (i = 0; i < numFields; i++) {

        if (theField.value.indexOf("net-price-") = "0") {

          theField.setAction("Format", 'AFNumber_Format(2, 2, 0, 0, "\u20ac", false)');

        }

      }

       

      Can anyone offer me some advice on this?