samedi 23 juillet 2016

Get parameter broken

I have an issue with a get parameter function, I have 2 parameters engTrackid and eng. The parameters are added automatically to my URL links. I need to grab the eng parameter, but instead it grabs the engTrackId and breaks it.

I.e. www.test.com/reg?engTrackid=123&eng=456

My page has a registration page, after submit, it should pass eng value to the TY page, but it looks like this:

www.test.com/ty?eng=rackid=456 instead of www.test.com/ty?eng=456

This is the function I'm using:

function getUrlVars() {
  var vars = {};
  var parts = window.location.href.replace(
    /[?&]+([^=&]+)=([^&]*)/gi,
    function(m,key,value) {
      vars[key] = value;
    }
  );
  return vars;
}
var elq = getUrlVars()["elq"];

As a note, I can't change the order of the parameters :(

Aucun commentaire:

Enregistrer un commentaire