Forum Moderators: open
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx!= -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
Then I'm using this in the body to display the field values in the appropriate places.
C1 = unescape(params["C1"]); document.write(C1);
The problem I'm having it that empty fields display as "undefined" I'd like for empty fields to equal a string of " ", obviously while not disturbing the fields that already contain a value.
I attempted to add
if (typeof params == "undefined") {params = ' ';}
to the getParams function but it did change anything.
I'm fairly new to javascript so your help is very much appreciated.