Support

Home Forums Event Espresso Premium Registration Form: Conditional Logic

Registration Form: Conditional Logic

Posted: July 22, 2017 at 9:21 pm


mcgilloweek

July 22, 2017 at 9:21 pm

Hello,
I’m creating a registration form and there are some questions that only need to be be asked based on choices made in earlier DROPDOWN menu selections. I’d like for the unnecessary questions to be hidden.

I understand that some custom functions are required to allow this conditional logic. The best resource I have found for this is:

https://eventespresso.com/topic/add-other-to-dropdown/

However, the sample code provided in that discussion doesn’t work for me, even after I change the 104/105 to my question IDs.

My questions:
1) Is it possible the sample code would be different for me because I’m using EE4 and the user in the earlier post was using EE3? If so, how does the sample code need to change?
2) If the question I’m targeting is not a TEXT type, do I need to change that in the sample code as well? (Example, instead of label[for=TEXT_105], should it be label[for=DECIMAL_105]

Below is the sample code from previous EE3 example (which isn’t working for me):

function ee_custom_show_question_conditionally() {
wp_add_inline_script(
‘validation’,
‘jQuery( document ).ready(function($) {
var text = $(“label[for=TEXT_105], .TEXT_105”);
$(text).hide();
$(“.DROPDOWN_104”).change(function() {
$(this).val() == “other” ?
$(text).show() :
$(text).hide();
});
});’
);
}
add_action( ‘wp_enqueue_scripts’, ‘ee_custom_show_question_conditionally’, 11 );


Josh

  • Support Staff

July 24, 2017 at 10:29 am

Hi there,

You are correct, the code from that other thread will only work with the forms from Event Espresso 3. The html markup for the forms in EE4 is completely different.

So instead of using selectors like:
label[for=TEXT_105], .TEXT_105

you use this instead:
#ee-single-page-checkout-dv div[id*=\'-105-input-dv\']

The support post ‘Registration Form: Conditional Logic’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso