Friday, April 2, 2010

Getting the Querystring using Javascripts

The following javascript displays how to get a querystring value from a URL.

function RetreiveValues()
{
//Getting the URL part
var querystring = location.search.substring(1);
//Getting the string value
var objectTypeCode = getQuerystring('Flag');
}


function getQuerystring(key, default_)
{
if (default_ == null) default_ = "";
key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
var qs = regex.exec(window.location.href);
if (qs == null)
return default_;
else
return qs[1];
}

No comments:

Post a Comment

Retrieving Calendar of a Bookable Resource in Dynamics

There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...