How do I show the name of the item and its description in a dropdown?

Created by Joshua Miller, Modified on Sun, 23 Mar at 7:41 PM by Joshua Miller

Step-by-step guide

  1. Click on Modules.
  2. Select the Module with the appropriate form field.
  3. Select Forms tab.
  4. Select Field List button "Create/Update Fields"
  5. Use the filter to search for the relevant field.
  6. Select Edit on the field.
  7. Select Custom JavaScript tab.
  8. In the “Filter” section type


for (var i = 0, len = fieldScope.items.length; i < len; i++) {

var item = fieldScope.items[i];

if (!item.descriptionAppended) {

var separator = '-';

               item.descriptionAppended = true;

               item.text = item.text + separator + item.description;

           }

}

return fieldScope.items;

(Example: If you want a diverse set of separator characters, then you need to change the value of the separator variable in the JavaScript.)

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article