I have the following script which is suppose to grab all parameters (and their values) passed in through query string, put them in an array, and display the parameter value in any text field on a page that has its "title" attribute the same as the parameter name.
The problem is that this script only works in IE and not Firefox. Is there a way to make it compatible for both? Or is there a function that I am using in this script that does not work in FF?
Any help is greatly appreciated guys. Thanks in advance.
The problem is that this script only works in IE and not Firefox. Is there a way to make it compatible for both? Or is there a function that I am using in this script that does not work in FF?
Any help is greatly appreciated guys. Thanks in advance.
Code:
// GET AN ARRAY OF PASSED PARAMETERS...
var qsParm = new Array();
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;
}
}
// GET ALL ELEMENTS ON HTML DOCUMENT...
var elementColl = document.body.all;
var i;
for (i = 0; i < elementColl .length; i++)
{
if (elementColl[i] != null && elementColl[i].getAttribute("title") != null)
{
// CHECK IF PASSED PARAMETER [ARRAY KEY] MATCHES A TITLE ATTRIBUTE ON ONE OF THE HTML ELEMENTS...
var x = elementColl[i].getAttribute("title");
if (qsParm[x] != null)
{
// SET THE ELEMENT VALUE TO THE PARAMETER VALUE [ARRAY VALUE]...
elementColl[i].value = qsParm[x];
//elementColl[i].parentNode.parentNode.parentNode.style.display = "none";
}
}
}