Home All Groups Group Topic Archive Search About

OT: Javascript for an ASP guy?



Author
2 Mar 2005 5:02 AM
Byron
Hey,

I'm pretty good with ASP but Javascript has always confused me so I tend
to use pre-built stuff that I can just plug-in and only tweak if
absolutely necessary.

I'm working on something now that needs to client side dynamism and I
know how I'd do it with with ASP, but I'm sure if Javascript can do
this, or where to look.

Can you, with Javascript, set a variable to a specific value on an
onClick action, and have an if...then in another spot on the page check
the value of that variable and if it meets the right condition toggle
between images?

Seems like you should be able to, but I'm often wrong.

Author
2 Mar 2005 5:21 AM
MarkP
Yes you can. Make sure that the variable is declared in the HEAD section (in
script tags of course), that way it acts like a local variable (global to the
file).

You can then reference that variable elsewhere.
Author
2 Mar 2005 8:01 AM
Byron
In article <C1EF509B-5281-4BC7-AF4F-6FFF38A5A***@microsoft.com>,
Ma***@discussions.microsoft.com says...
> Yes you can. Make sure that the variable is declared in the HEAD section (in
> script tags of course), that way it acts like a local variable (global to the
> file).
>
> You can then reference that variable elsewhere.
>

Is this considered "Setting a cookie?" That's what I find tutorials on
when I google it.
Author
2 Mar 2005 11:13 AM
Bob Barrows [MVP]
Byron wrote:
> In article <C1EF509B-5281-4BC7-AF4F-6FFF38A5A***@microsoft.com>,
> Ma***@discussions.microsoft.com says...
>> Yes you can. Make sure that the variable is declared in the HEAD
>> section (in script tags of course), that way it acts like a local
>> variable (global to the file).

While it is preferable to declare all global variables in a single location.
it is not necessary. The only requirement is that they be declared (inside
of a script block) outside of a function.
<head></head>
<body>
<script>
var globvar = 25
.....


globvar can be accessed by other scripts in this page.


>>
>> You can then reference that variable elsewhere.
>>
>
> Is this considered "Setting a cookie?" That's what I find tutorials on
> when I google it.

No. That is much different. This is called "setting a variable", i.e.,
setting aside a location in memory to contain a value that can be referenced
later by code running in the same scope. Cookies are written to the client's
disk, and therefore can be referenced by more than one page. Variables are
in memory, and are destroyed when they go out of scope.

Byron, client-side questions (whether vbscript or javascript) should be
posted in one of the .scripting groups, either .scripting.jscript, or
..scripting.vbscript if you want an IE-only solution.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Author
2 Mar 2005 8:25 AM
Evertjan.
Byron wrote on 02 mrt 2005 in microsoft.public.inetserver.asp.general:

> I'm pretty good with ASP but Javascript has always confused me so I tend
> to use pre-built stuff that I can just plug-in and only tweak if
> absolutely necessary.
>
> I'm working on something now that needs to client side dynamism and I
> know how I'd do it with with ASP, but I'm sure if Javascript can do
> this, or where to look.
>

<script language=javascript runat=server>
response.write('Do you think Javascript means clientside');
response.write(' and so is off topic in asp?<br><br>');
response.write('Do you think ASP-guy equals vbscript-guy?');
</script>

if your answer is yes then
        please reconsider
end if

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Author
2 Mar 2005 8:31 AM
Byron
In article <Xns960D5FD9D4881eejj99@194.109.133.29>,
exjxw.hannivo***@interxnl.net says...
Show quote
> Byron wrote on 02 mrt 2005 in microsoft.public.inetserver.asp.general:
>
> > I'm pretty good with ASP but Javascript has always confused me so I tend
> > to use pre-built stuff that I can just plug-in and only tweak if
> > absolutely necessary.
> >
> > I'm working on something now that needs to client side dynamism and I
> > know how I'd do it with with ASP, but I'm sure if Javascript can do
> > this, or where to look.
> >
>
> <script language=javascript runat=server>
> response.write('Do you think Javascript means clientside');
> response.write(' and so is off topic in asp?<br><br>');
> response.write('Do you think ASP-guy equals vbscript-guy?');
> </script>
>
> if your answer is yes then
>         please reconsider
> end if
>
>

How clever. I said it was off topic. Thanks.
Author
2 Mar 2005 8:49 AM
Evertjan.
Byron wrote on 02 mrt 2005 in microsoft.public.inetserver.asp.general:
>>
>> <script language=javascript runat=server>
>> response.write('Do you think Javascript means clientside');
>> response.write(' and so is off topic in asp?<br><br>');
>> response.write('Do you think ASP-guy equals vbscript-guy?');
>> </script>
>>
>> if your answer is yes then
>>          please reconsider
>> end if
>>
> How clever. I said it was off topic. Thanks.

Cleverness aside, if that means "yes", then you clearly don't know that
many ASP-guys code preferably in serverside javascript/jscript.

But why, if I may ask, do you ask a clearly clientside javascript question
as OT in this ASP NG and not in one of the javascript or jscript NGs.

Is that because you are an ASP-guy? That wouldn't sound like a valid
reason.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

AddThis Social Bookmark Button