DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Javascript Getparams

10.20.2007
| 4836 views |
  • submit to reddit
        similar to <a href="http://snippets.dzone.com/posts/show/4682">JavaScript GetVars Array</a> and <a href="http://snippets.dzone.com/posts/show/4681">Parse GetVars with JavaScript</a> this fetches all the get variables with corresponding values.
function getparams(s){
  a = s.match(/[^&?=]*=[^&?=]*/g);
  r = new Array();
  for (i=0; i<a.length; i++) {
  	r[i] = new Array(a[i].match(/[^&?=]*/)[0], a[i].match(/=([^&?]*)/)[0].replace('=', ''));
  }
  return(r);
}
    

Comments

Snippets Manager replied on Sun, 2007/08/05 - 4:28pm

nice