Copy Label for List Field Drop Downs

Copy the label (rather than the value) for Drop Downs in List fields.

Instructions

  1. Install our free Custom Javascript for Gravity Forms plugin. Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
  2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.

Code

Filename: gpcc-copy-label-list-field-drop-downs.js

/**
* Gravity Perks // Copy Cat // Copy Label for List Field Drop Downs
* https://gravitywiz.com/documentation/gravity-forms-copy-cat/
*
* Copy the label (rather than the value) for Drop Downs in List fields.
*
* Instructions:
* 1. Install our free Custom Javascript for Gravity Forms plugin.
*    Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
*/
gform.addFilter( 'gppc_copied_value', function( value, $elem, data ) {
  if ( $.isNumeric( value ) ) {
    var found = jQuery( '#field_' + data.sourceFormId + '_' + data.source ).find( 'option[value="' + value + '"]' ).text();
    value = found ? found : value;
  }
  return value;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.