Skip to main content

Get QueryString value using javascript

var vars = [], hash;
var q = document.URL.split('?')[1];
if(q != undefined){
q = q.split('&');
for(var i = 0; i < q.length; i++){
hash = q[i].split('=');
vars.push(hash[1]);
vars[hash[0]] = hash[1];
}
}

You can now access a querystring value simply by referecning the vars array like

vars["someinput"] ;

Comments

Popular posts from this blog