Support

Home Forums Event Espresso Premium Add jquery to inline php script to hide questions for certain tickets Reply To: Add jquery to inline php script to hide questions for certain tickets

Reply To: Add jquery to inline php script to hide questions for certain tickets

Author Replies
radiusinvestigations # Posted on May 15, 2018 at 11:12 am

So from my understanding, the question is set to not required by default and admin. If that is the case, would I only need to use jquery to make the question set to required on certain ticket types? Here’s what I have atm:

‘function ee_custom_hide_question() {
wp_add_inline_script(
‘single_page_checkout’,
‘jQuery( document ).ready( function( event ){
function hideQuestion(item, index) {
jQuery( “.spco-attendee-panel-dv.spco-attendee-ticket-” + item ).
find( “[id^=\’ee-reg-form-qstn-grp-veterans-pricing-\’]” ).hide();
};
[“4”, “5”, “6”, “9”].forEach(hideQuestion);
});’,
‘function requireQuestion(item, index) {
jQuery( “.spco-attendee-panel-dv.spco-attendee-ticket-” + item ).
find( “[id^=\’ee-reg-form-qstn-grp-veterans-pricing-\’]” ).RemoveAttr(“required”, false).attr(“required”, true);
};
[“14”, “13”, “12”, “11”].forEach(requireQuestion);’
);
}
add_action( ‘wp_enqueue_scripts’, ‘ee_custom_hide_question’, 11 );’

Saved, but the question doesn’t appear as required for the tickets types that show the question. Tried removing the .Removeattr() part and just having the .attr and it still wouldn’t work.

Do NOT follow this link or you will be banned from the site!