This is the most important function you will every need in your online endeavors. It is called getparm. You use it by calling it into a variable.
Example:
var recordnumber=getparm('parm'); [be sure your parameter match's what was passed]
Here is the function to get the parameter;
function getparm(name)
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
I found this function posted on the internet while working on a project. Similar solutions are posted all over the internet. Over the years, I have learned that if you need a solution, let your fingers do the walking. If you can't find what your looking for WALK AWAY AND THEN COME BACK, works every time.
Additional Resources:
http://www.netlobo.com/url_query_string_javascript.html
No comments:
Post a Comment