Skip to content

Instantly share code, notes, and snippets.

@angusluk
Last active August 27, 2018 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angusluk/b5547bfd3f248e4b62d970cbd009439e to your computer and use it in GitHub Desktop.
Save angusluk/b5547bfd3f248e4b62d970cbd009439e to your computer and use it in GitHub Desktop.
gtm sample on logical questions
<script>
$( document ).ready(function() {
function hideFirstLogicalQuestions(){
$("#registration-form > section.questions > div:nth-child(9)").hide()
$("#registration-form > section.questions > div:nth-child(10)").hide()
$("#registration-form > section.questions > div:nth-child(11)").hide()
$("#registration-form > section.questions > div:nth-child(12)").hide()
$("#registration-form > section.questions > div:nth-child(13)").hide()
$("#registration-form > section.questions > div:nth-child(14)").hide()
$("#registration-form > section.questions > div:nth-child(15)").hide()
}
function showFirstLogicalQuestions(){
$("#registration-form > section.questions > div:nth-child(9)").show(1000)
$("#registration-form > section.questions > div:nth-child(10)").show(1000)
$("#registration-form > section.questions > div:nth-child(11)").show(1000)
$("#registration-form > section.questions > div:nth-child(12)").show(1000)
$("#registration-form > section.questions > div:nth-child(13)").show(1000)
$("#registration-form > section.questions > div:nth-child(14)").show(1000)
$("#registration-form > section.questions > div:nth-child(15)").show(1000)
}
// hide when load the page
hideFirstLogicalQuestions();
//FirstLogicalQuestions
$("#registration-form > section.questions > div:nth-child(8) > div > div > div > div > ul > li:nth-child(2), #registration-form > section.questions > div:nth-child(8) > div > div > div > div > ul > li:nth-child(2) > a").click( function() {
showFirstLogicalQuestions();
})
$("#registration-form > section.questions > div:nth-child(8) > div > div > div > div > ul > li:nth-child(1), #registration-form > section.questions > div:nth-child(8) > div > div > div > div > ul > li:nth-child(3)").click( function() {
hideFirstLogicalQuestions();
})
//mobile
$("#attendee_answers_attributes_7_chosen_choice_id").on('change', function() {
if( this.value == 140802){
showFirstLogicalQuestions();
} else {
hideFirstLogicalQuestions();
}
})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment