Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- JavaScript to read a URL query string?


dhdweb - 12:06 am on Oct 29, 2002 (gmt 0)


Better yet, can anyone solve this problem?

Using the following script:

function getArgs() {
var args = new Object();
var query = location.search.substring(1);
var pairs = query.split("&");
for(var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('=');
if (pos == -1) continue;
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
args[argname] = unescape(value);
}
return args;
}
var args = getArgs();
if (args.a) a = parseInt(args.a);
document.write(a);

If the query is "?a=01" thru "?a=07" the output is 1 thru 7
But, (this is the killer!)
If the query is "?a=08" or "?a=09" the output is 0

Please help!

dhdweb


Thread source:: http://www.webmasterworld.com/javascript/216.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com