If the code is in a .JS file it won't work as the JS file is not considered an Active Server Page, therefore any ASP commands will not be run.
A workaround might be to call the JS file pass the values on a querystring - then use javascript to get the querystring value.