Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active November 6, 2018 01:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/183209d5239cc07ec94f9ebbfb017d40 to your computer and use it in GitHub Desktop.
Save joshfeck/183209d5239cc07ec94f9ebbfb017d40 to your computer and use it in GitHub Desktop.
Example of how to conditionally hide/show a text question based on a drop down question value. Works with Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// In this example the *text* question div class is .ee-reg-qstn-13-input-dv
// and the *dropdown* question input class is .ee-reg-qstn-12
function ee_custom_show_question_conditionally() {
wp_add_inline_script(
'ee_form_section_validation',
'jQuery( document ).ready(function($) {
var text = $(".ee-reg-qstn-13-input-dv");
$(text).hide();
$(".ee-reg-qstn-12").change(function() {
$(this).val() == "other" ?
$(text).show() :
$(text).hide();
});
});'
);
}
add_action(
'wp_enqueue_scripts',
'ee_custom_show_question_conditionally',
11
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment