Skip to content

Instantly share code, notes, and snippets.

@scyt
Last active February 4, 2020 22:22
Show Gist options
  • Save scyt/2e76b3f7c95669dbf96cc0189304a490 to your computer and use it in GitHub Desktop.
Save scyt/2e76b3f7c95669dbf96cc0189304a490 to your computer and use it in GitHub Desktop.
Gravity Perks // GP Copy Cat // Last Item In List
<script type="text/javascript">
/**
* Gravity Perks // GP Copy Cat // Last Item In List
*
* Only copy the last item in a list field to the target field
*
* @version 1.0
* @author Scott Buchmann <scott@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
* @copyright 2020 Gravity Wiz
*/
// Update "123" with target Field ID
gform.addFilter( 'gppc_copied_value', function( value, $elem, data ) {
if( data.target == 123 && value ) {
var lastIndex = value.lastIndexOf(' ');
value = value.substring(lastIndex + 1);
}
return value;
} );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment