jQuery(window).on('load', function(){
// check whether any matching string for email exists, otherwise do not run function // encodedna.com/javascript/check-if-url-contains-a-given-string-using-javascript.htm
if (window.location.href.indexOf('email=') > 0) {
// https://www.sitepoint.com/url-parameters-jquery/ jQuery.urlParam = function (name) {
var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.search);
if ( results == null){
return null;
}
else {
return results[1] || 0;
}
}
var str = jQuery.urlParam('email');
var res = str.replace("%40", "@");
console.log(res); //email
console.log(jQuery.urlParam('fname')); //first name
console.log(jQuery.urlParam('lname')); //lname name
jQuery('input[name="billing_email"]').val(res);
jQuery('input[name="billing_first_name"]').val(jQuery.urlParam('fname'));
jQuery('input[name="billing_last_name"]').val(jQuery.urlParam('lname'));
} // end check for string
}); // end on load