You can't access < %= % > expressions in a separate file since the separate javascript file is not an ASPX/ASP page hence it doesn't evaluate that value.
There are a few ways around this.
One is you can set a global variable in your main ASPX/ASP file :
< script type="text/javascript>
var sessionVar = "< %= Session["mySessionVar"] % >";
< /script>
Put that on the bottom before the form tag of your main form and then in the .js file you should be able to reference sessionVar as a global variable.
+++ Rick ---
>I have all my Javascript in a separate file linked to an html page. I am trying to get the session variable value from within a Javascript function. If the function code is on the html page it works, but it won't work in the linked file. I have written the value to the page with VBScript. I use a hidden text to pass to the Session variable. The Session variable has the correct value. Anyone know why I cannot get the Session variable value when the js code is in a linked file?
>Code sample below:
>
>// fills comboxbox for vendors
>function SelectVendor(classid) {
> var selCls = < %=Session("nSelCls")% >;
> if (selCls != 0){
> startForm.cboClasses.selectedIndex = selCls;
> classid=selCls;
> }
> var vendors=xmlClasses.childNodes(0).childNodes(classid);
> startForm.cboVendor.options.length=0;
> for (i=0;i<vendors.childNodes.length;i++) {
> oOption=document.createElement("OPTION");
> o=vendors.childNodes(i);
> new_option=o.getAttribute("vendor_name");
> oOption.text=new_option;
> oOption.value=new_option;
> startForm.cboVendor.options.add(oOption);
> }
> SelectPayType(classid,0);
>}
>