Created
September 11, 2014 19:40
-
-
Save fiftyandfifty/215771d48e72149b967b to your computer and use it in GitHub Desktop.
Simple example using Donately form.js of manipulating the recurring option & sending a second email to the OnbehalfOf of person
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>test</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
jQuery( window ).load(function() { | |
// pre-check the recurring option | |
jQuery('#donately-recurring-donation').prop('checked', true); | |
// this is our function to handle any messages that we get | |
function receiveMessage(event){ | |
// try to get the message event data | |
try {var data = JSON.parse(event.data);} | |
catch (e) {var data = event.data;} | |
// if the event is 'donately.success' then do this | |
if(data.event == 'donately.success'){ | |
var onbehalf = jQuery('#donately-onbehalf').val(); | |
console.log('send email to onbehalf of person', onbehalf); | |
} | |
} | |
// depending on the browser type, there are different ways to get the event message | |
if (window.addEventListener){ | |
window.addEventListener('message', receiveMessage, false); | |
} | |
else if (window.attachEvent){ | |
window.attachEvent('message', receiveMessage); | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<div style="width:400px;margin:50px auto"> | |
<script src='https://www.dntly.com/assets/js/v1/form.js' | |
data-donately-id='198' | |
data-donately-amount='20' | |
data-donately-ssl='true' | |
data-donately-onbehalf='true'> | |
</script> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment