-4

I want to retrieve the information between “tmad=” and “&tmpageid” using javascript.

example: www.url.com/tmad1234&tmpageid88

asimo
  • 1
  • You can find the solution here : http://stackoverflow.com/questions/831030/how-to-get-get-request-parameters-in-javascript – GPierre Dec 16 '14 at 17:40
  • If you are wondering why you are getting downvotes, try reading this: http://stackoverflow.com/help/how-to-ask – The Head Rush Dec 16 '14 at 17:42

1 Answers1

0

Assuming you mean www.url.com/tmad=1234&tmpageid88 the following should do the trick

function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split('&');
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split('=');
        if (decodeURIComponent(pair[0]) == variable) {
            return decodeURIComponent(pair[1]);
        }
    }
    console.log('Query variable %s not found', variable);
}

getQueryVariable("tmad");
Rajdeep Dosanjh
  • 1,157
  • 1
  • 9
  • 20