Calling the database and determining which links should be displayed should be logic on the server side. What you could do is have a file, userlinks.asp for example, which outputs as a javascript file. I'm not familiar with ASP so I couldn't help you with this, but in PHP I'd have a file that looked something like this ( majority commented for brevity ):
userlinks.php
Code:
<?php
// set the Content type to javascript, so the browser knows how to treat it
header("Content-type: application/x-javascript");
?>
<script type="text/javascript">
<?php
// query the database for the links, and store them in an associative array, $links
foreach($links as $link) {
// determine which link we need and then output... for example:
echo "addSubmenuItem(\"".$link['path']."\",\"".$link['name']."\",\"\");";
}
?>
</script>
Your javascript could then always rely on that file to setup the links for you. It's important to remember that Javascript is on the client side. Therefore, it doesn't have access to the database on your server. The only way the javascript could gain access is through ajax, but that would be very poor design and a waste of resources.
Bookmarks