Clear Search on Selection

Clear the search term(s) after a selection has been made.

Instructions

  1. Install this snippet with our free Custom JavaScript plugin. https://gravitywiz.com/gravity-forms-code-chest/

Code

Filename: gpadvs-clear-search-on-select.js

/**
 * Gravity Perks // Advanced Select // Clear Search on Selection
 * https://gravitywiz.com/documentation/gravity-forms-advanced-select/
 *
 * Clear the search term(s) after a selection has been made.
 *
 * Instructions:
 *
 * 1. Install this snippet with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 */
gform.addFilter( 'gpadvs_settings', function( settings, gpadvs ) {
	if ( gpadvs.formId == GFFORMID ) {
		settings.onItemAdd = function(){
			this.setTextboxValue('');
			this.close();
		};
	}
	return settings;
} );

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.