Created
June 16, 2021 10:16
-
-
Save henihan/d5987071bffc21346b66966157d13ada to your computer and use it in GitHub Desktop.
Event Espresso - Conditionally hide/show question groups based on a radio button question value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ee_custom_show_question_conditionally() { | |
wp_add_inline_script('ee_form_section_validation','jQuery( document ).ready(function($) { | |
var text = $("div[id^=\'ee-reg-form-qstn-grp-Silver-\']"); | |
$(text).hide(); | |
$(".ee-reg-qstn-88").change(function() { | |
//Uncomment Below to Test value of Question so you can put in the IF statement "Yes" in this example | |
//var test=$(this).val(); | |
//Uncomment Below to Show the Value to the browser | |
//alert(test); | |
$(this).val() == "Yes" ? $(text).show() : $(text).hide(); | |
}); | |
var text2 = $("div[id^=\'ee-reg-form-qstn-grp-Gold-\']"); | |
$(text2).hide(); | |
$(".ee-reg-qstn-89").change(function() { | |
//Uncomment Below to Test value of Question so you can put in the IF statement "Yes" in this example | |
//var testG=$(this).val(); | |
//Uncomment Below to Show the Value to the browser | |
//alert(testG); | |
$(this).val() == "Yes" ? $(text2).show() : $(text2).hide(); | |
}); | |
var text3 = $("div[id^=\'ee-reg-form-qstn-grp-Platinum-\']"); | |
$(text3).hide(); | |
$(".ee-reg-qstn-90").change(function() { | |
//Uncomment Below to Test value of Question so you can put in the IF statement "Yes" in this example | |
//var testP=$(this).val(); | |
//Uncomment Below to Show the Value to the browser | |
//alert(testP); | |
$(this).val() == "Yes" ? $(text3).show() : $(text3).hide(); | |
}); | |
var text4 = $("div[id^=\'ee-reg-form-qstn-grp-Diamond-\']"); | |
$(text4).hide(); | |
$(".ee-reg-qstn-91").change(function() { | |
//Uncomment Below to Test value of Question so you can put in the IF statement "Yes" in this example | |
//var testD=$(this).val(); | |
//Uncomment Below to Show the Value to the browser | |
//alert(testD); | |
$(this).val() == "Yes" ? $(text4).show() : $(text4).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