0 Replies Latest reply on Apr 4, 2016 5:18 PM by Agherian

    How do I add any typed text in a combo-box to its own dropdown list?


      Hi, I was searching on the internet for a solution to this. I want to make a Combo-box which lets the user to type additional text besides the prepopulated list in it (that is an option under combo-box properties for pdf form), but then I want this combo-box to add such user-input text into its own list, and then add the same text on many other combo-boxes. For the sake of example, imagine 7 combo-boxes that lists food, one for each day of the week; suppose there are no noodles on the premade list. the user types "noodles" and then "noodles" is added to the dropdown list of all the 7 combo-boxes.


      I found a js pdf guide with this code as an example:

          var CB = this.getField("myList");

          CB.insertItemAt("sam", "s", 0); /* inserts sam to top of list l */


      And I do believe that is close to my intent. But being new to JS I'm not so sure. For instance, if I added a JS script in the combo-box itself, I wouldn't have in that code the text itself, rather customizing it to add whatever the user types in the box, and then add it to the dropdown list.
      Also I'm not clear on what the "s" in the example stands for. it seems to be

      "cExport (optional) The export value of the field when this item is selected. If
      not provided, the cName is used as the export value."


      I want the export to be the same as the text, should I use ', "s",' or just skip it, having the code somewhat like 'CB.insertItemAt("text", 0)' ?


      To add this text to multiple combo-boxes I believe some code with intervals 'for (i=0, i<7,i++);' should do the trick, following with 'this.getField("CB"+i).insertItemAt', having the combo-boxes named similarly only the number at the end being 0,1,2,3,4,5,6.


      So my main question is how do I change the "sam" in the code example into the text being typed by the user?




      EDIT: Tried this, didnt work:
          var CB = this.getField("CB_food0");
          for (i=0;i<7;i++) {
      if ("CB.value" != "") {
      this.getField("CB_food"+i).insertItemAt("CB.value", "s", 0);

      I'd like to have also a condition that checks the texts already inside the dropdown list so the same text isnt added over and over.