2 Replies Latest reply on Jun 2, 2016 1:44 AM by alexh90310518

    Changing multiple text field values by checking for a word/words in their name.

    alexh90310518 Level 1


      So in my document I have a load of text fields all named roughly similar just with slight variations in their name.






      ... Etc


      The way it all works is each individual text box represents a setting for a single item, so in this case there are 4 items.

      The way these settings are selected is the user presses a button which spawns a copy of a template page.

      On this page are a bunch of check boxes, dropdowns and buttons, these particular text fields display the value of one dropdown box.

      This is so that when the user is finished with the spawned page it can be deleted and all the information is stored on the main page for later in the process.

      Due to the way the items work means that the fields can either display a 'None selected' or a selected option BUT they cannot differ in the option that was selected.


      FldTxt "None Selected"

      FldTxt1 "Option2 Selected"

      p1.templateName.FldTxt "Option2 Selected"

      p1.templateName.FldTxt "None Selected"


      I hope that explains the theory behind it all.

      So what I am wondering is could I set the values of these text fields by searching for a keyword in their name? Eg. if the field has "FldTxt" in it's name and it's value is not equal to "None Selected", change its value to the value of the most recent dropdown.

      The reason I want to do it in this roundabout way is because there is no predefined number of these text fields, there could be just 2 or 200 as it depends on the number of items in the form.

      So I imagine it would go something like this;


      for (var i=0; i<this.numFields; i++) {
          var f = this.getField(this.getNthFieldName(i));
          var nameSearch = //search for keywords in a field name
          var dropdown = //the name of the dropdown
          if (f.nameSearch == "FldTxt" && if f.type = "textfield") {
              if (f.value !== "None Selected") {
                  f.nameSeach.value = dropdown.value;

      Apologies if the syntax is wrong or even impossible but I'm not exactly sure what I'm asking to check for I just know what the outcome would be.

      I know we can search for words in a document so I'm wondering if that's possible for field names