function miniDonationForm() {
$('.DDLamounts > ul').each(function() {
var $select = $('');
$(this).find('a').each(function() {
var $option = $('');
$option.attr('value', $(this).attr('href')).html($(this).html());
$select.append($option);
});
$(this).replaceWith($select);
});
$('.DDLamounts select > option').each(function(){
var optionValue = $(this).text();
$(this).attr('value',optionValue);
});
var giveonlineURL = '/giveonline';
var firstDDLval = $('.DDLamounts select > option').first().val();
$('.nextButton a').attr("href", giveonlineURL + '?referrer=DonationForm' + '&GiftAmount=' + firstDDLval);
$('.DDLamounts select').on('change', function(){
var donationAmount = $('.DDLamounts select').val().replace('$',"");
$('.nextButton a').attr("href", giveonlineURL + '?referrer=DonationForm' + '&GiftAmount=' + donationAmount);
});
}
// get URL paramters
function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return sParameterName[1];
}
}
}
// set URL paramters as variables
var giftPre = decodeURI(getUrlParameter('GiftAmount'));
var referrerPre = decodeURI(getUrlParameter('DonationForm'));
var gift = giftPre.replace(/[^\d\.]/g,'');
var referrer = referrerPre.split('+').join(' ');
function postURL() {
if (referrer) {
if (gift) {
if ($('input[id*="rdoOther"]').length > 0) {
$('input[id*="rdoOther"]').trigger('click');
}
$('input[id*="txtAmount"]').val(gift).attr('value',gift);
}
}
}
$(document).ready(function(){
if ( $('.miniDonationForm').length > 0 ) {
miniDonationForm();
}
if ( $('.DonationFormTable').length > 0 ) {
setTimeout(function(){
postURL();
},2000);
}
});