Var Assignment.

N

n2K

I have a var in a javascript like so:
<script language="javascript">

var timerID = null;
var timerRunning = false;
var timeIncrement = 0;
LATER in the code I need to assign a session var to the local var like
so....

timeIncrement = session("incTime")

How do I do this?

I keep getting errors like "an exception of type MS jscript runtime...
Object expected was not handled"

tx,

NB
 
E

Evertjan.

n2K wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:
timeIncrement = session("incTime")

How do I do this?

You cannot mix serverside and clientside code that way.

timeIncrement = '<% = session("incTime") %>'

mind the [single] quotes
 
N

n2K

Been there tried that. What happens is the STRING '<% = session("incTime")
%>' is assigned to timeIncrement!

???

Evertjan. said:
n2K wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:
timeIncrement = session("incTime")

How do I do this?

You cannot mix serverside and clientside code that way.

timeIncrement = '<% = session("incTime") %>'

mind the [single] quotes
 
E

Evertjan.

n2K wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:
Evertjan. said:
n2K wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:
timeIncrement = session("incTime")

How do I do this?

You cannot mix serverside and clientside code that way.

timeIncrement = '<% = session("incTime") %>'

mind the [single] quotes
Been there tried that. What happens is the STRING '<% =
session("incTime") %>' is assigned to timeIncrement!

???

[please do not toppost on usenet]

Not true, if used in an .asp file on an asp server.

If you don't use ASP, why post here?
 
B

Bob Barrows [MVP]

So leave out the quotes,

timeIncrement = <% = session("incTime") %>

or do an explicit type conversion.

Bob Barrows
Been there tried that. What happens is the STRING '<% =
session("incTime") %>' is assigned to timeIncrement!

???

Evertjan. said:
n2K wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:
timeIncrement = session("incTime")

How do I do this?

You cannot mix serverside and clientside code that way.

timeIncrement = '<% = session("incTime") %>'

mind the [single] quotes
 
B

Bob Barrows [MVP]

Bob said:
So either leave out the quotes,

timeIncrement = <%= session("incTime") %>

or do an explicit type conversion.
.... in your client-side code, not inside the server-side brackets

Bob Barrows
 
N

n2K

Regardless how I try this, the <% and %> do not appear in the typical
hilight Yellow color!

Bob Barrows said:
So leave out the quotes,

timeIncrement = <% = session("incTime") %>

or do an explicit type conversion.

Bob Barrows
Been there tried that. What happens is the STRING '<% =
session("incTime") %>' is assigned to timeIncrement!

???

Evertjan. said:
n2K wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:

timeIncrement = session("incTime")

How do I do this?


You cannot mix serverside and clientside code that way.

timeIncrement = '<% = session("incTime") %>'

mind the [single] quotes

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
N

n2K

Actually it is true, I've added watches and it is assigned theString value.
And yes, in an ASP page on an ASP server. Not trying to be difficult, simply
laying out what results I am getting.

n2k

Evertjan. said:
n2K wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:
Evertjan. said:
n2K wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:

timeIncrement = session("incTime")

How do I do this?


You cannot mix serverside and clientside code that way.

timeIncrement = '<% = session("incTime") %>'

mind the [single] quotes
Been there tried that. What happens is the STRING '<% =
session("incTime") %>' is assigned to timeIncrement!

???

[please do not toppost on usenet]

Not true, if used in an .asp file on an asp server.

If you don't use ASP, why post here?
 
N

n2K

Perhaps if I include the entire code snippet, it may help.

SNIPPET BEGINS

<script language="javascript">

function startclock() {
stopclock();
timeValue = '<%=session("timerInc")%>';
timerID = setInterval("increment()", timeValue);
timerRunning = true;
document.images.bar.src=image00.src;
}
</script>

SNIPPET END

Thanks
n2k
 
B

Bob Barrows [MVP]

n2K said:
Regardless how I try this, the <% and %> do not appear in the typical
hilight Yellow color!
Not for me either in a script block (assuming you are using Interdev). The
yellow-highlight is only applied in the html area. Ignore the lack of
highlighting. It works even though Interdev does not recognize it.

Bob Barrows
 
B

Bob Barrows [MVP]

n2K said:
Perhaps if I include the entire code snippet, it may help.

SNIPPET BEGINS

<script language="javascript">

function startclock() {
stopclock();
timeValue = '<%=session("timerInc")%>';

As I said before, if you want timeValue to be a number, either get rid of
the quotes

timeValue = <%=session("timerInc")%>;

Or use a conversion function on the variable to convert it to a number. The
unary + operator can be used for this:
timeValue = '<%=session("timerInc")%>';
timerID = setInterval("increment()", +timeValue);
timerRunning = true;
document.images.bar.src=image00.src;
}
</script>

Look at the page's source after running it (comment out the setInterval
statement) to see what is happening

Bob Barrows
 
N

n2K

Bob, I tried to remove the quotes as you had previouslsy mentioned and I
still get the same error.

n2k
 
B

Bob Barrows [MVP]

I don't rememeber the mentioning of an error... oh! the "object expected"
error? Can you post the page's source?

Are you sure the problem isn't the increment() function? Does it work if you
hard-code a numeric value into timeValue rather than using the
response.write?

Let me try to duplicate this ... nope - it works fine for me. I think the
issue is elsewhere.

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top