the following two functions came from a javascript forum and work fine. the if loop at the end is my attempt to write different text to the document depending on the variable “entry” in the URL. however, no matter what i do, it will only write the result for the first condition (it writes “entry=1” no matter what entry is). please help! what’s wrong with my if loop?
thanks,
corey
function QueryString(key)
{
var value = null;
for (var i=0;i<QueryString.keys.length;i++)
{
if (QueryString.keys[i]==key)
{
value = QueryString.values[i];
break;
}
}
return value;
}
QueryString.keys = new Array();
QueryString.values = new Array();
function QueryString_Parse()
{
var query = window.location.search.substring(1);
var pairs = query.split(“&”);
for (var i=0;i<pairs.length;i++)
{
var pos = pairs[i].indexOf(‘=’);
if (pos >= 0)
{
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
QueryString.keys[QueryString.keys.length] = argname;
QueryString.values[QueryString.values.length] = value;
}
}
}
QueryString_Parse();
entryID=QueryString(“entry”);
if (entryID=’1′) {
document.write (‘entry=1’);
} else if(entryID=’2′) {
document.write (‘entry=2’);
} else{
document.write (‘no entry specified’);
}