Return to Snippet

Revision: 52324
at October 20, 2011 04:21 by cpres


Initial Code
<script type="text/javascript">

		var $j = jQuery.noConflict();

    jQuery(document).ready(function () {
		var title1 = "Single Occurance Downloader / 3 Days given to download";
		var title2 = "Member Level Supporter / 1 Year Membership";
		var title3 = "Gold Level Membership / 1 Year Membership with AN INCREDIBLY THANK YOU!!!";
        jQuery(".donation").change(function () {
                var checkDonateLevel = jQuery(this).attr("name");
                var donValue = jQuery(this).val();
				var applyButton = function (index) { // Sets the the proper values for the Donate button
					jQuery('input[name=a3]').val(donValue); // Whatever money value they select is how much they pay
					switch(checkDonateLevel)
					{
					case 'l1' :
						jQuery('input[name=t3]').val("D"); // Set to Days
						jQuery('input[name=p3]').val("3"); // Set to 2 Days
						jQuery('input[name=item_number]').val("1"); // Set user to Level 1
						jQuery('input[name=item_name]').val(title1); // Set description given to Paypal Page
						break;
					case 'l2' :
						jQuery('input[name=t3]').val("Y"); // Set to Years
						jQuery('input[name=p3]').val("1"); // Set to 1 Year
						jQuery('input[name=item_number]').val("2"); // Set user to Level 2
						jQuery('input[name=item_name]').val(title2); // Set description given to Paypal Page
						break;
					case 'l3' :
						jQuery('input[name=t3]').val("Y"); // Set to Years
						jQuery('input[name=p3]').val("1"); // Set to 1 Year
						jQuery('input[name=item_number]').val("3"); // Set user to Level 3
						jQuery('input[name=item_name]').val(title3); // Set description given to Paypal Page
						break;
					}
				}
				jQuery(".donation").ready(applyButton);
                var resetButton = function (index) { // Resets all the other donation dropdowns
                        var donLevel = jQuery(this).attr("name");
                        if (donLevel != checkDonateLevel) {
							jQuery(this).val(''); 
                        }
                }
				jQuery(".donation").each(resetButton);
        });
    });
</script>

Initial URL
cameronpreston.com/membership-options

Initial Description
If you are using the Wordpress plugin S2 Member and want to accept donations at various levels. First create the form with a class of donation and 3 different dropdowns, then change the values of the hidden inputs using jQuery (which is this script)

Initial Title
Wordpress: S2 Member Plugin: Tiered Donation Support

Initial Tags


Initial Language
jQuery