I saw this demonstrated at Empower 2016 and realize that this is a very basic scripting question, however, upon implementation I am unable to figure out what I have wrong. When the user is taken to the Thank You page for form submission I want the form to show all sections and not retain pagination. I think i have something wrong in the section "Check if in submission mode". Any help would be appreciated.
/* Variables holding navigation section information */
var section1 = $('.section1 h1:first').text();
var section2 = $('.section2 h1:first').text();
var section3 = $('.section3 h1:first').text();
var section4 = $('.section4 h1:first').text();
var section5 = $('.section5 h1:first').text();
var section6 = $('.section6 h1:first').text();
var section7 = $('.section7 h1:first').text();
/* Open up the div's and name them, then insert before a form id */
$('<div class="navbar"><div class="navitem info">' + section1 + '</div><div class="navitem medi">' + section2 + '</div><div class="navitem guard">' + section3 + '</div><div class="navitem emerg">' + section4 + '</div><div class="navitem waive">' + section5 + '</div><div class="navitem upld">' + section6 + '</div><div class="navitem sig">' + section7 + '</div></div>').appendTo('#q150');
/* Creation of navigation bar at the bottom which moves the pages */
$('<input class="navitem medi" value="--> Next: ' + section2 + " -->" + '" type="button">').appendTo('.section1');
$('<input class="navitem info" value="<-- Previous: ' + section1 + " <--" + '" type="button"> <input class="navitem guard" value="--> Next: ' + section3 + " -->" + '" type="button">').appendTo('.section2');
$('<input class="navitem medi" value="<-- Previous: ' + section2 + " <--" + '" type="button"> <input class="navitem emerg" value="--> Next: ' + section4 + " -->" + '" type="button">').appendTo('.section3');
$('<input class="navitem guard" value="<-- Previous: ' + section3 + " <--" + '" type="button"> <input class="navitem waive" value="--> Next: ' + section5 + " -->" + '" type="button">').appendTo('.section4');
$('<input class="navitem emerg" value="<-- Previous: ' + section4 + " <--" + '" type="button"> <input class="navitem upld" value="--> Next: ' + section6 + " -->" + '" type="button">').appendTo('.section5');
$('<input class="navitem waive" value="<-- Previous: ' + section5 + " <--" + '" type="button"> <input class="navitem sig" value="--> Next: ' + section7 + " -->" + '" type="button">').appendTo('.section6');
$('<input class="navitem upld" value="<-- Previous: ' + section6 + " <--" + '" type="button">').appendTo('.section7');
/* Holds the function which links the sections to the nav bar clicks */
$('.navitem').on('touchstart click', function () {
$('.section1, .section2, .section3, .section4, .section5, .section6, .section7, .Submit').hide();
$('.navbar').find('.navitem').removeClass('selected');
if ($(this).hasClass('info')) {
$('.section1').show();
$('.navbar').find('.info').addClass('selected');
}
else if ($(this).hasClass('medi')) {
$('.section2').show();
$('.navbar').find('.medi').addClass('selected');
}
else if ($(this).hasClass('guard')) {
$('.section3').show();
$('.navbar').find('.guard').addClass('selected');
}
else if ($(this).hasClass('emerg')) {
$(".section4").show();
$('.navbar').find('.emerg').addClass('selected');
}
else if ($(this).hasClass('waive')) {
$('.section5').show();
$('.navbar').find('.waive').addClass('selected');
}
else if ($(this).hasClass('upld')) {
$('.section6').show();
$('.navbar').find('.upld').addClass('selected');
}
else if ($(this).hasClass('sig')) {
$('.section7, .Submit').show();
$('.navbar').find('.sig').addClass('selected');
}
})
/* When user hits submit, the form opens up completely and shows any required fields */
$('.navitem.info').trigger('click');
$('.Submit').click(function(){
$('.section1, .section2, .section3, .section4, .section5, .section6, .section7').show();
$('.navitem').hide();
});
// check if in submission mode
if ($('.School input').prop('tagName')!='INPUT') {
//hide navigation bar, navigation and submission btn
$('.navigationbar').hide();
$('.navitem').hide();
$('.Submit').hide();
//show all sections
$('.sections').show();
}