|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OT: Javascript for an ASP guy?
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. 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. 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 Is this considered "Setting a cookie?" That's what I find tutorials on > script tags of course), that way it acts like a local variable (global to the > file). > > You can then reference that variable elsewhere. > when I google it. Byron wrote:
> In article <C1EF509B-5281-4BC7-AF4F-6FFF38A5A***@microsoft.com>, While it is preferable to declare all global variables in a single location. > 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). 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. >> No. That is much different. This is called "setting a variable", i.e., >> You can then reference that variable elsewhere. >> > > Is this considered "Setting a cookie?" That's what I find tutorials on > when I google it. 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" 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 <script language=javascript runat=server>> 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. > 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) 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: How clever. I said it was off topic. Thanks.> > > 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 > > Byron wrote on 02 mrt 2005 in microsoft.public.inetserver.asp.general:
>> Cleverness aside, if that means "yes", then you clearly don't know that >> <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. 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) |
|||||||||||||||||||||||