Padding Padding
Janet
Systems
 Register  Login 
Telephone  01628 566 178
Website Design, Hosting and Software Services
  Search 
Padding
corner Padding corner
Padding Padding
corner Padding corner
 Javascript Articles

A JavaScript function to illicit the value for a parameter in a querystring. We can use JavaScript to get the various parameters from within a querystring. In the function given below I have used the JavaScript split function to break up the querystring into an array. I then use a dor loop to step through the array to find the required parameter. A second use of the split function will yield the value of the parameter

function getParameter( parameterName ) {
  var queryString = window.location.search.substring(1).toLowerCase();
  //alert(queryString);
  //if (queryString.length==0) {return "null";}
  var parameters = new Array();
  parameters = queryString.split('&');
  for(var i = 0; i < parameters.length; i++) {
    //alert(parameters[i]);
    //alert(parameters[i].indexOf(parameterName));
    if (parameters[i].indexOf(parameterName.toLowerCase())>=0) {
      //alert(parameters[i]);
      var parameterValue = new Array();
      parameterValue = parameters[i].split('=');
      return parameterValue[1];
    }
  }
  return "null";
}

var ModuleId = getParameter('ModuleId');

I have left in place some alerts, which may be uncommented to help you in testing your use of the function.

NAT March 2006


This article viewed: 4665 times Back

Copyright © 2004-2007 Janet Systems Ltd.

 Print   

DotNetNuke Website design and hosting from £15.00 per month. More...

Looking for a website design company in the Thames Valley, call us on 01628 566178

DotNetNuke Modules
DotNetNuke Modules availalble from Janet Systems

DotNetNuke Skins
DotNetNukeSkins.gif

from Janet Systems

Padding
Copyright 2002-2008 Janet Systems Ltd.   Terms Of Use  Privacy Statement Tuesday, May 13, 2008