Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //hide the second, third and fourth steps from the user.
- $("document").ready(function(){
- //Hide additional steps and the differences between the two steps if they have Javascript
- function hideSteps() {
- //hide the divs
- $("#step1").hide();
- $("#step2").hide();
- $("#step3").hide();
- $("#step4").hide();
- $("#makingAOneTimeGift").hide();
- $("#makingARecurringGift").hide();
- }
- //Show the submit buttons since we're going to take them through the steps
- function showSubmitSteps() {
- $("#submit_first").show();
- $("#submit_second").show();
- $("#submit_third").show();
- $("#return_question").show();
- $("#return_first").show();
- $("#return_second").show();
- $("#return_third").show();
- }
- function replaceRecurringDonationValue() {
- //make our variables so we don't forget
- var perDonationValue = 0;
- var numberOfMonths = 0;
- var TotalRecurringDonationValue = 0;
- //give them their correct values
- perDonationValue = $("#recurringDonationValue").val();
- numberOfMonths = $("#numberOfMonths").val();
- //ensure that the maximum number of months is enforced.
- if(numberOfMonths > 60) {
- alert("Donations can last for a maximum of 60 months.");
- $("#numberOfMonths").val(60);
- }
- TotalRecurringDonationValue = perDonationValue * numberOfMonths;
- $("#TotalRecurringDonationValue").val(TotalRecurringDonationValue);
- }
- function replaceDonationAmount() {
- //check which they used
- var donationAmount = 0;
- var OneTimeDonation = $("[name=oneTimeDonationValue]").val();
- var RecurringDonation = $("[name=RecurringDonationValue]").val();
- if(OneTimeDonation != 0) {
- donationAmount = OneTimeDonation;
- } else {
- donationAmount = RecurringDonation;
- }
- $("#showTotalDonationAmount").text(donationAmount);
- }
- //Let's add the ability to show and hide fields via the checkboxes
- function addInteractiveFields() {
- //Class Year Dropdown
- $("#ifClassScholashipsSelected").css("display","none");
- $(".enableClassYearSelection").click(function(){
- if ($("input[name=Class_Scholarships]:checked").val() == "class_scholarships") {
- $("#ifClassScholashipsSelected").slideToggle("fast"); //Slide Down Effect
- } else {
- $("#ifClassScholashipsSelected").slideToggle("fast"); //Slide Up Effect
- }
- });
- //Other Funds Dropdown
- $("#ifOtherFundsSelected").css("display","none");
- $(".enableOtherFunds").click(function(){
- if ($('input[name=OtherFunds]:checked').val() == "other_funds" ) {
- $("#ifOtherFundsSelected").slideDown("fast"); //Slide Down Effect
- } else {
- $("#ifOtherFundsSelected").slideUp("fast"); //Slide Up Effect
- }
- });
- //In Memory Of Dropdown
- $("#ifInMemoryOfSelected").css("display","none");
- $(".enableInMemoryOf").click(function(){
- if ($('input[name=InMemoryOf]:checked').val() == "in_memory_of" ) {
- $("#ifInMemoryOfSelected").slideDown("fast"); //Slide Down Effect
- } else {
- $("#ifInMemoryOfSelected").slideUp("fast"); //Slide Up Effect
- }
- });
- //In Honor Of Dropdown
- $("#ifInHonorOfSelected").css("display","none");
- $(".enableInHonorOf").click(function(){
- if ($('input[name=InHonorOf]:checked').val() == "in_honor_of" ) {
- $("#ifInHonorOfSelected").slideDown("fast"); //Slide Down Effect
- } else {
- $("#ifInHonorOfSelected").slideUp("fast"); //Slide Up Effect
- }
- });
- }
- hideSteps();
- showSubmitSteps();
- addInteractiveFields();
- $("#recurringDonationValue").change(replaceRecurringDonationValue());
- $("#numberOfMonths").change(replaceRecurringDonationValue());
- //they chose a one-time gift
- $("#oneTimeGift").click(function() {
- $("#makingAOneTimeGift").show();
- $("#typeOfGift").text("one-time");
- $("#step0").slideToggle("slow");
- $("#step1").slideToggle("slow");
- return false; // prevent the link from submitting
- });
- $("#recurringGift").click(function() {
- $("#makingARecurringGift").show();
- $("#typeOfGift").text("total recurring");
- $("#step0").slideToggle("slow");
- $("#step1").slideToggle("slow");
- return false; // prevent the link from submitting
- });
- //let's add the "Next" buttons to make this move forward
- $("#submit_first").click(function() {
- $("#step1").slideToggle("slow");
- $("#step2").slideToggle("slow");
- replaceDonationAmount();
- return false; // prevent the link from submitting
- });
- $("#submit_second").click(function() {
- $("#step2").slideToggle("slow");
- $("#step3").slideToggle("slow");
- replaceDonationAmount();
- return false;
- });
- //let's add the "Previous" button
- $("#return_question").click(function() {
- $("#step1").slideToggle("slow");
- $("#step0").slideToggle("slow");
- $("#makingARecurringGift").hide();
- $("#makingAOneTimeGift").hide();
- return false;
- });
- $("#return_first").click(function() {
- $("#step2").slideToggle("slow");
- $("#step1").slideToggle("slow");
- return false;
- });
- $("#submit_third").click(function() {
- $("#step3").slideToggle("slow");
- $("#step4").slideToggle("slow");
- return false;
- });
- $("#return_second").click(function() {
- $("#step3").slideToggle("slow");
- $("#step2").slideToggle("slow");
- return false;
- });
- $("#return_third").click(function() {
- $("#step4").slideToggle("slow");
- $("#step3").slideToggle("slow");
- return false;
- });
- $("#submit_form").click(function() {
- return true; //submit the form using ajax!
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement