Tuesday, April 3, 2012

Parsing query string values in the extraqs parameter

If you want to get values of query string parameters that are inside the extraqs query string field in your crm form then you can call the getExtraqsParam function. It takes two values: they key is the param whose value you want to get to and the query is the actual query string which you can find through window.location.search property. Note that that window.locaiton.search only returns the query string part of the url.
 function getExtraqsParam(key,query)
        {   //Get the any query string parameters and load them
            //into the vals array

            var vals = new Array();
           
                vals = query.substr(1).split("&");
                for (var i in vals)
                {
                    vals[i] = vals[i].replace(/\+/g, " ").split("=");
                }
                //look for the parameter named 'extraqs'
                var found = false;
                var returnVal=null;
                for (var i in vals)
                {

                    if (vals[i][0].toLowerCase() == "extraqs")
                    {
                       
                         
                         returnVal= vals[i][1];

                          break;
                    }
                }

                return parseExtraqs(key,returnVal);                     

        }

function parseExtraqs(key,val)
{

    var returnVal;
    var vals;
    vals=decodeURIComponent(val).split("&");
    for (var i in vals)
     {
         vals[i] = vals[i].replace(/\+/g, " ").split("=");
         if (vals[i][0]==key)
        returnVal=decodeURIComponent(vals[i][1]);
     }
return returnVal;

}
Happy Crming!

No comments:

Post a Comment