Last active
June 6, 2016 11:29
-
-
Save craiggrella/dd5e3388e253c0fa72032b28a34a6c56 to your computer and use it in GitHub Desktop.
Adds ability to collect donation amounts in string query passed in URL. Great for adding auto amounts in buttons and text inside emails.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Added by CraigGrella.com for pinning amount to string query | |
// Used for creating buttons in emails with links for specific dollar amounts | |
function getQueryVariable(variable) | |
{ | |
var query = window.location.search.substring(1); | |
var vars = query.split("&"); | |
for (var i=0;i<vars.length;i++) { | |
var pair = vars[i].split("="); | |
if(pair[0] == variable){return pair[1];} | |
} | |
return(false); | |
} | |
jQuery(function($){ | |
var amt = getQueryVariable("donation_amt"); | |
if (!amt) return; | |
$('#donation_amount_'+amt).attr('checked', true); | |
// Uncomment to Automatically progress to second stage | |
// $('.progress-stage-button-next').click(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment