#page-title{ display:none; } .breadcrumb{ display:none; } #quiz { font-family:Arial, Helvetica, sans-serif; font-size:8px; font-weight:400; } #quiz_wrapper { width: 629px; background-color: #FFFFFF; padding: 5px; margin:0; float: left;} .image_container { position:relative; } #white_bg { background-color: #FFFFFF; position: relative; margin-bottom: 0px; padding:0px;} #agree_1, #agree_2 { position: absolute; top: 17px; left: 254px;} #agree_2 { left: 536px;} #quiz_wrapper iframe{ margin: 23px 19px 0 0; position:absolute; top:0; right:0; left:auto;} #quiz_wrapper label { width: 265px; min-height: 30px; position: relative; display: inline-block; margin-left: 15px; padding: 5px 35px 5px 5px; vertical-align:middle; font-size: 12px; cursor: pointer;} .grey_row { background-color: #efefef;} .white_row { background-color: #FFFFFF;} #quiz_wrapper input[type=checkbox] { display: none;} #quiz_wrapper span { background:url(http://img1.coastalliving.timeinc.net/sites/default/files/image/2014/06/thumb/checkboxes.png) top left no-repeat; position: absolute; top: 2px; left: 243px; width: 20px; height: 24px;} #quiz_wrapper .checked span { background-position: 0 -24px; } #quiz_wrapper form {padding: 40px 0 20px 20px;} .no-sidebars #quiz_wrapper { width: 100%; background-color: #FFFFFF; padding: 0; margin:0; float: left;} .no-sidebars #agree_2 { display: none;} .no-sidebars #quiz_wrapper label { width: 100%; min-height: 30px; position: relative; display: inline-block; margin-left: 15px; padding: 10px 30px 10px 5px; vertical-align:middle; font-size: 12px; cursor: pointer;} .no-sidebars #quiz_wrapper form {padding: 40px 0 0 0;} #quiz_wrapper input {margin: 25px 0 0 475px;} .no-sidebars input { margin: 16px 0 0 190px;} .no-sidebars .mob_row_white {background-color:#FFFFFF;} .no-sidebars .mob_row_grey {background-color: #efefef;} .no-sidebars #quiz_wrapper span { background:url(http://img1.coastalliving.timeinc.net/sites/default/files/image/2014/06/thumb/checkboxes.png) top left no-repeat; position: absolute; top: 5px; left: auto; right: 10px; width: 20px; height: 24px;} .no-sidebars #quiz_wrapper .checked span { background-position: 0 -24px; } .no-sidebars #white_bg{ width: 100%; padding-bottom: 25px; -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ -moz-box-sizing: border-box; /* Firefox, other Gecko */ box-sizing: border-box; /* Opera/IE 8+ */} .no-sidebars #quiz_wrapper label { display: block; margin: 0 auto; } .no-sidebars .submit_btn{ margin:25px auto !important; display:block; } .no-sidebars #agree_1, .no-sidebars #agree_2{ position:inherit; float:right; left:0; } .no-sidebars #quiz_wrapper iframe{ right: 3%; max-width: 23%; position: absolute; top: 5%; margin: 0; }
How obsessed with summer are you?
 
$( ".checkbox_element" ).change(function() { if ( this.checked) { $(this).closest("label").addClass("checked"); } else { $(this).closest("label").removeClass("checked"); } }); $.each($('#quiz_wrapper label'), function() { if ( $("#" + $(this).attr("for")).attr("checked") ) { $(this).addClass("checked"); } else { } }); /***** Intercept form submit, prevent default action and redirect to corresponding results page *****/ $( "#quiz" ).submit(function( event ) { var count = 0; // Initialize # of options selected by user /***** Loop through each option *****/ $.each($('#quiz_wrapper label'), function() { if ( $("#" + $(this).attr("for")).attr("checked") ) { count++; // If checked, count = count + 1 } }); event.preventDefault(); var url = window.location.href.indexOf("coastalliving.com/m/"); if(url > 0){ baseURL = "http://www.coastalliving.com/m/"; } else{ baseURL = "http://www.coastalliving.com/"; } // Find the correct range for # of choices, then set URL variable in window.location function if (count > 30 && count <= 40){ window.location = baseURL+'general/how-obsessed-with-summer-are-you-result-4?val=' + count; //redirects to results 4 } else if (count > 20){ window.location = baseURL+'general/how-obsessed-with-summer-are-you-result-3?val=' + count; //redirects to results 3 } else if (count > 10){ window.location = baseURL+'general/how-obsessed-with-summer-are-you-result-2?val=' + count; //redirects to results 2 } else if (count > 0){ window.location = baseURL+'general/how-obsessed-with-summer-are-you-result-1?val=' + count; //redirects to results 1 } // if none selected, alert the user and stay on the page if (count == 0) { alert("Please check at least one item to see how obsessed with summer you are!"); // stay on page } });