Cookie in form from URL issue

Hi,

I have the following code which is supposed to add a cookie based on teh URL into a form. However, iot is not working.

Can anyone see anything wrong with the below code?

function gup(name) {
    return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
}

$( document ).ready(function() {
var curRef = $.cookie('ref');
if (curRef != null) {
if ((curRef != "mydefault") && (curRef.substring(0, 3) != "ppc")) {
$('input[name=tmp]').val("discount");
	$('input[name=company]').val($.cookie('ref'));
}
}

if (gup("ref") != "null") {
var curRefURL = gup("ref");
if ((curRefURL != "mydefault") && (curRefURL.substring(0, 3) != "ppc")) {
	$('input[name=tmp]').val("discount");
	$('input[name=company]').val(curRefURL);
}

}
});

Thanks!

null != “null”

Thanks, I’ve changed that, but the script doesn’t seem to be applying the cookie reference. Any ideas what else I could have wrong?

Thanks

have you tested that gup() does what you think it does? have you checked what the variables really contain?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.