Hello! I need code that will take the variable (8KWM2MPUSCMU4) from this link: http://laricketson.com/life-changing-webinar/?LARicketson&IP=8KWM2MPUSCMU4 and add it to the end of my button link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=xxx (in place of the x's.) The code will be close to this I think, but I am not sure how to implement. Please advise: var first = getUrlVars()["ip"]; alert(first); function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&#]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } Can anyone help? Should only take a few minutes. Thank you!
Is laricketson.com your website? You can do it with PHP with $_GET. Explain technologies you are using. is 8KWM2MPUSCMU4 always this long? string with known number of characters at the end of URL?
var inputUrl = "http://laricketson.com/life-changing-webinar/?LARicketson&IP=8KWM2MPUSCMU4", outputUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=xxx"; function getID(inputUrl) { return inputUrl.substring(inputUrl.indexOf("IP=") + 3); } function putId(IdToAdd, outputUrl){ return outputUrl.replace("xxx", IdToAdd); } alert(putId(getID(inputUrl), outputUrl)); Code (markup):
Hi! "IP=8KWM2MPUSCMU4" shows that the var name is IP, not 8KW... So you need to take core of the IP variable. If i were you i would a regular expression like: url = window.location.href; var expr = /IP=([^&]+)/; result = url.match(expr); alert(result); Code (markup): The result might be in result[1], you can check what the alert returns