Conditional Logic using a field that populates with no result

Experimental Snippet 🧪

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

Code

Filename: gppa-conditional-logic-when-no-results.js

/**
 * Gravity Perks // Populate Anything // Conditional Logic using a field that populates with no result
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * Experimental Snippet 🧪
 *
 * 1. Install this snippet with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 */

gform.addAction('gform_post_conditional_logic_field_action', function (formId, action, targetId, defaultValues, isInit) {
    // replace 26 with the field ID of the field that gets dynamically populated with No Results
	var targetValue = $( '#input_GFFORMID_26 :selected' ).val();
	if ( targetValue === 'Check' ) {
        // replace 27 with the field ID of the field that needs to be displayed with conditional logic
		$( '#field_GFFORMID_27' ).show();
	}
});

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.