I've got a page X that is supposed to have hyperlinks to pages A, B, and C if certain conditions are met. What I'm hoping to do is (on the server as the page is being built) is prune out hyperlinks that don't meet my conditions. The way I would like this to be structured is that in the Javascript function that is building the HTML for the links on X, eval a function that exists in A, B, and C where a true/false is returned which tells me whether or not to include the link.
I've written it so far so that X dynamically pieces together the name of the appropriate function to call in A, B, and C based off of their names and uses eval. The problem is that eval doesn't seem to know where the functions are located.
Since this is server-side, I don't believe that I can use the tag because I think that's for client-side code. I don't want to use the at the top because I want X to be loosely coupled with A, B, and C.
This is Javascript in ASP pages running on IIS.
Any suggestions as to how I can make the eval locate the function on the server is appreciated.
mj
[edit]
function shouldLink(filename)
{
filename = "a.asp";
var splits = filename.split(".");
var file = splits[0].toUpperCase() + "_ShouldLink()"; // A_ShouldLink() function name built here
var exec = "<!--#include virtual=\"a.asp\" -->";
exec += "eval( " + file + " );";
try{
return eval( exec );
} catch( err ){
}
return true;
}
Basically at the eval here I want the function named A_ShouldLink() to be called (which resides in a.asp).