6 Replies Latest reply on Aug 5, 2008 11:45 AM by gkaiseril

    Help with Combo Box

      I would like to create a combo box where users can see a full description of choices in the drop down but will only print the code for that choice after selection is made. For example, I have a combo box designated for property status. This is what I would like the user to see in the drop down.

      01 - NONE
      02 - BURNED

      If "Burned" is selected, the field would only show and print "02"

      One alternate way of doing this i guess would be to designate a tooltip for each combo box item, but I couldn't see an option for that either. I am designing in Acrobat 8 Pro.

      I would greatly apreciate any suggestions or help.
        • 1. Re: Help with Combo Box
          gkaiseril MVP & Adobe Community Professional
          You will need to use 2 fields, the first is the combo box for slection of the item and this field will have the "visible will not print" property and the export value for the selection will be the number only. And a second text field that will hold the value of the selected item of the combo box and will have the property of "Hidden but printable". You should be able to stack the fields without any problems. If you do not want the option showing selection showing you will need to do a lot of specialized coding to hide and show field upon entry into a field and custom formatting.
          • 2. Re: Help with Combo Box
            Level 1
            Thanks for the info. Just tried this and noticed that the text field is dropping the "0" from my export value. Any work around? Also, do you know if it is possible to create tooltips for each combo box item? In this particular form, I have limited space for each field. It might be easier to have users hover over the two-digit codes for the definitions. Really appreciate the help!
            • 3. Re: Help with Combo Box
              MarkWalsh Level 4
              You could use a custom format script on your combo box:

              var n = event.value

              if (n == "01 - NONE") {
              event.value = "01"
              } else if (n == "02 - BURNED") {
              event.value = "02"
              } ...etc...

              or even simpler, just get the first 2 digits of event.value if they will always be the value you want to display.
              • 4. Re: Help with Combo Box
                gkaiseril MVP & Adobe Community Professional
                The easiest way is to use the ".valueAsString" property or the ".toString()" method to convert the assumed numeric value to a string value.
                • 5. Re: Help with Combo Box
                  Level 1
                  Thanks Mark. That seems to be a lot easier than the two field method and solves the dropped "0". Geo, I just did a search of the two methods you mentioned but could not find any examples.
                  • 6. Re: Help with Combo Box
                    gkaiseril MVP & Adobe Community Professional
                    For the "Custom calculation" for the text field:

                    // "valueAsString" property form Acrobat API JavaScript
                    event.value = this.getField("ComboBoxFieldName").valueAsString;

                    // or

                    // ".toString()" method from Mozilla JS Reference. One has to add the leading zero.
                    event.value = "0" + this.getField("ComboBoxFieldName").value.toString();

                    // or
                    // format result with the "util" object and ".printf()" method.
                    event.value = util.printf("%,002.0f", this.getField("ComboBoxFieldName").value);