1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Passing Parameters Via Query Strings

2. The Read Function

Join the Discussion

Questions? Comments?

More of this Feature

Write Querystrings Read Querystrings

We can easily set up a Javascript function that will retrieve the query string and load an array with the values passed in the query string. Here it is. This function goes into the head section of our page.

var qsParm = new Array();
function qs() {
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
qsParm[key] = val;

The only other thing that we need to do is to initialize entries in the array for the fields that we want the page to process and to actually call the above function to read the querystring.

1 | 2 | 3

©2017 About.com. All rights reserved.