I am trying to lowercase a query string and get the value even if the URL is with capital letters.
This is works - I can get the value:
?serialid=1234
This does not work - I Cannot get the value (Capital S):
?Serialid=1234
I would like to match both cases.
My script:
$(document).ready(function () {
var a = getQueryString("serialid");
$('#SerialIdHP').val(a);
});
function getQueryString(key) {
var vars = [],
hash;
var hashes = (window.location.href.slice(window.location.href.indexOf('?') + 1).split('&')).toString().toLowerCase();
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars[key];
}