J
Jim Adamson
I have created a web page that receives names and values from a URL
string of another page e.g.
http://hostname/resolve?sublibrary=JMLibrary&collection=Elton&shelfmark=LM
36TY
... and decodes the names/values from the ? onwards, doing all the
seperation of the ampersands.
Here is the "decoder" that I found at
http://www.tek-tips.com/faqs.cfm?fid=5442
==========================================
function getValue(varname)
{
// First, we load the URL into a variable
var url = window.location.href;
// Next, split the url by the ?
var qparts = url.split("?");
// Check that there is a querystring, return "" if not
if (qparts.length == 0)
{
return "";
}
// Then find the querystring, everything after the ?
var query = qparts[1];
// Split the query string into variables (separates by &s)
var vars = query.split("&");
// Initialize the value with "" as default
var value = "";
// Iterate through vars, checking each one for varname
for (i=0;i<vars.length;i++)
{
// Split the variable by =, which splits name and value
var parts = vars.split("=");
// Check if the correct variable
if (parts[0] == varname)
{
// Load value into variable
value = parts[1];
// End the loop
break;
}
}
// Convert escape code
value = unescape(value);
// Convert "+"s to " "s
value.replace(/\+/g," ");
// Return the value
return value;
}
// end hide -->
</script>
==============================================
I would like to know how to make name/value pairs available to an "if,
then, else statement"
i.e. how i could expand the getValue function so that it would accept
something like:
if(collection == 'Elton')
....do such and such e.g. open a pop-up window.
I suppose what I am asking is how do I reference these name/value
pairs so I can do something with them.
thanks a lot
Jim
string of another page e.g.
http://hostname/resolve?sublibrary=JMLibrary&collection=Elton&shelfmark=LM
36TY
... and decodes the names/values from the ? onwards, doing all the
seperation of the ampersands.
Here is the "decoder" that I found at
http://www.tek-tips.com/faqs.cfm?fid=5442
==========================================
function getValue(varname)
{
// First, we load the URL into a variable
var url = window.location.href;
// Next, split the url by the ?
var qparts = url.split("?");
// Check that there is a querystring, return "" if not
if (qparts.length == 0)
{
return "";
}
// Then find the querystring, everything after the ?
var query = qparts[1];
// Split the query string into variables (separates by &s)
var vars = query.split("&");
// Initialize the value with "" as default
var value = "";
// Iterate through vars, checking each one for varname
for (i=0;i<vars.length;i++)
{
// Split the variable by =, which splits name and value
var parts = vars.split("=");
// Check if the correct variable
if (parts[0] == varname)
{
// Load value into variable
value = parts[1];
// End the loop
break;
}
}
// Convert escape code
value = unescape(value);
// Convert "+"s to " "s
value.replace(/\+/g," ");
// Return the value
return value;
}
// end hide -->
</script>
==============================================
I would like to know how to make name/value pairs available to an "if,
then, else statement"
i.e. how i could expand the getValue function so that it would accept
something like:
if(collection == 'Elton')
....do such and such e.g. open a pop-up window.
I suppose what I am asking is how do I reference these name/value
pairs so I can do something with them.
thanks a lot
Jim