When the user clicks on the submit button after entering their username
and password, it calls a function (below) and I get an "Object expected"
javascript error.
This is the function:
function ftn_process()
{
var str_uid = document.login.str_uid.value;
var str_pswrd = document.login.str_pswrd.value;
if (str_uid != "" && str_pswrd != "")
{
Session("UserID") = ""
Session("Logged") = "";
Session("userLevel") = -1;
document.forms("login").submit();
}
}
I get the error at Session("UserID");
Does anybody have any ideas on this problem?
Yhanks
Rob
*** Sent via Developersdex http://www.developersdex.com ***
Possibly because you didn't define Session function anywhere in your
code.
It has to be a function because you are calling it in the function
contect.
Oops... Correction: you cannot assign to function results. This way
Session("UserID") = "";
has no sense whatsoever.
Could you provide a link to get an idea of what are you doing?
Hi
The Session object is a host object (i.e. not native) that is made
available to JavaScript code processed on the server in an ASP
pre-processing page.
Contrary to VK's comment, under ASP I believe the Session object's
properties are accessed using ' ( ) ' notation, so in an ASP page,
Session("UserID") = "" is I think valid.
However, looking at the above code, it looks like you are running this
in a client web page. The ASP Session object cannot be acessed by code
running on the client. It is only available to that JavaScript which
runs on the server **before** the ASP page is sent to the client.
Regards
Julian
The problem is that this was working on the development server but when
we moved it to production, that's when I get the error so that's why I
thought it was an IIS setting issue.
I would send a link but it's an intranet application.
The page language is javascript as well,
<% @Language="javascript" %>
but my function is within a <script> block.
I don't know if that makes a difference.
Regards
I meant that this statement is not valid for ECMAScript-compliant
engines including javascript. Whatever is valid for server-side ASP
instructions is beyond of anyone's power but Microsoft.
> Thanks Julian,
>
> The problem is that this was working on the development server but when
> we moved it to production, that's when I get the error so that's why I
> thought it was an IIS setting issue.
> I would send a link but it's an intranet application.
>
> The page language is javascript as well,
> <% @Language="javascript" %>
>
> but my function is within a <script> block.
>
> I don't know if that makes a difference.
Learn to understand the difference between
server side executed code and clientside executed code.
Serverside code is processed first
and the resulting html [perhaps with client side code]
is sent as a stream to the clientside, the browser mostly,
and the clientside cannot even see the serverside code.
============ test.asp ==================
<% @Language='javascript' %>
<br>
<%
if (7>5) response.write('Hello world');
%>
<br>
<script type='text/javascript'>
document.write('good morning.');
</script>
=========================================
will send this html to the browser:
=======================================
<br>
Hello world
<br>
<script type='text/javascript'>
document.write('good morning.');
</script>
========================================
And the browser will display:
=======================================
Hello world
good morning.
========================================
Session variables are serverside variables,
and only their containing values can be sent to the client.
<%
response.write( session('theName') );
%>
So the session object only exist in the serverside code.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
The problem is most likely due to a missing runat="server" attribute in
your script tag. Your tag should look like:
<script type="javascript" runat="server">
...
</script>
Cheers
Chad