Skip to content

Instantly share code, notes, and snippets.

@surefirewebserv
Created August 27, 2016 15:23
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 surefirewebserv/089ee10698adca60b9d6f0148ecd0f51 to your computer and use it in GitHub Desktop.
Save surefirewebserv/089ee10698adca60b9d6f0148ecd0f51 to your computer and use it in GitHub Desktop.
<script>
var $ = jQuery;
$(document).ready( function() {
$('.shows select').change(function(){
var name = $(this).parent().parent().attr('class').split(' ');
var row = name[3];
var mainClass = row.split('--');
var values = $(this).val().split(' -- '); //Event-Date-Location
$('.location-' + mainClass[1] + ' input').val(values[2]);
$('.venue-date-' + mainClass[1] + ' input').val(values[1]);
if($(this).val() == 'Afro-Brazil Music, Dance & Drum Ensemble -- 11/09/15 -- Queens College' || $(this).val() == 'Vote for President-Pre-Election Year-Social Study -- 11/18/15 -- Queens College' || $(this).val() == 'Anti-Bullying Rockin' Musical - A Bully Free Zone -- 11/23/15 -- Queensborough PAC' || $(this).val() == 'Mistletunes-Rock "N" Roll-Multi-Cultural Celebration -- 12/02/15 -- Harlem Stage' || $(this).val() == 'Christmas Carol – Favorite Holiday Classical Story -- 12/09/15 -- Queensborough PAC' || $(this).val() == 'The Snow Queen - Hans Andersen's Fairy Tales -- 12/16/15 -- Queensborough PAC' || $(this).val() == 'MAGIC OF SCIENCE – Learning Science is Fun -- 02/03/16 -- Queensborough PAC' || $(this).val() == 'Jackie Robinson-Everybody's Hero -- 02/10/16 -- Queensborough PAC' || $(this).val() == 'Anti-Bullying Class Dismissed Project -- 02/10/16 -- Queens College' || $(this).val() == 'I Have A Dream-Story of Dr. Martin Luther King Jr. -- 02/11/16 -- Queensborough PAC' || $(this).val() == 'Slim Bodyology-Turning Kids Onto Healthy Eating -- 03/09/16 -- Queens College' || $(this).val() == 'Healthy Food Choices & Adventure of Nutrition -- 03/24/16 -- Queensborough PAC' || $(this).val() == 'Stone Soup and Other Stories – Multi-Cultural -- 03/31/16 -- Queensborough PAC') {
var cost = 8.5;
$('.venue-date-' + mainClass[1]).next('.time').children('div').children('select').html('<option value="">Select One</option><option value="10:00am">10:00am</option><option value="11:45am">11:45am</option>');
} else if ($(this).val() == 'HIP-HOP, Stepping, African, Breaking, Brazilian, Puerto Rican Dance -- 07/14/16 -- Queens College' || $(this).val() == 'HARLEM HOOPSTERS BASKETBALL GAME-SHOW -- 08/09/16 -- Queens College') {
var cost = 9;
$('.venue-date-' + mainClass[1]).next('.time').children('div').children('select').html('<option value="">Select One</option><option value="10:30am">10:30am</option><option value="12:15pm">12:15pm</option>');
} else if ($(this).val() == 'CIRCUS 3 DIMENSION, JUGGLING, FUN -- 07/28/16 -- Queens College') {
var cost = 10;
$('.venue-date-' + mainClass[1]).next('.time').children('div').children('select').html('<option value="">Select One</option><option value="10:30am">10:30am</option><option value="12:15pm">12:15pm</option>');
} else {
var cost = 9;
}
$('.tickets-' + mainClass[1] + ' input').change(function(){
var sum = $(this).val();
$('.price-' + mainClass[1] + ' input').val(sum * cost);
});
var sum = $('.tickets-' + mainClass[1] + ' input').val();
$('.price-' + mainClass[1] + ' input').val(sum * cost);
});
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]);
}
var locationTime = getURLParameter('location');
if(locationTime == 'newyork'){
$('.time select').html('<option value="">Select One</option><option value="10:00am">10:00am</option><option value="11:45am">11:45am</option>');
} else if(locationTime == 'longisland') {
$('.time select').html('<option value="">Select One</option><option value="10:30am">10:30am</option><option value="12:30pm">12:30pm</option>');
} else {
$('.time select').html('<option value="">Select One</option><option value="10:00am">10:00am</option><option value="12:30pm">12:30pm</option>');
}
$('a.calculate').bind("click", function (e) {
e.preventDefault();
updateTotals();
});
updateTotals = function(){
var total_sum = 0;
$('.cost input').each(function(){
total_sum += Number($(this).val());
});
$('.total-10 input').val(total_sum);
};
});
</script>
<style>
.gform_wrapper .top_label li.gfield.gf_inline select { width:215px !important; }
.location-01.gfield_contains_required label,
.venue-date-01.gfield_contains_required label,
.time.gfield_contains_required label,
.gf_inline.gfield_contains_required label { color:#f00; }
.gf_inline .gfield_required { display:none !important; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment