0 Replies Latest reply on Mar 13, 2008 12:44 PM by MarkWalsh

    Javascript to duplicate every field

    MarkWalsh Level 4
      Is there a way to duplicate every instance of a field in a document?

      I have a document with multiple fields (e.g. 'QTY.12345', 'QTY.12346', etc.) that occur in several places in the same document. Since I had no luck finding a way to set a field format to a non-javascript number format, I am trying to set up a script to duplicate every field wherever it exists in the document (the 'QTY.12345' field might exist on several pages, or more than once on the same page) and give the duplicated field the more advanced javascript functions.

      I can use the following to get every field in the 'QTY' family:

      var f = this.getField("QTY");
      var a = f.getArray();
      var v = 0.0;
      for (j =0; j < a.length; j++) {
      var fieldName = a[j].name
      app.alert ("Master field: " + fieldName)

      ...but I don't know how to find where each copy of the field exists in the document.

      My goal is to have a document which will give the user limited functionality if they have Javascript disabled, but will reveal the javascript enabled fields (and hide the non-js fields) and activate any javascript features on startup. When the file is closed, it will restore the document to the original non-javascript state.