faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

53 of 112 people (47%) answered Yes
Recently 3 of 10 people (30%) answered Yes


How do I pass a JavaScript variable to an ASP variable?

Apr 6th, 2008 19:42
ha mo, Dave Clark, Jean-Bernard Valentaten, Colin Fraser, Lynda Falconer,

Colin Fraser wrote: 
> Declare your variables globally, then it does not matter what use the
> variable is put to. VBScript and Javascript both use type variant so
> the type is not an issue. 
> However, once you have a variable and are using it in VBScript, you 
> may want to consider its sub-type, in which case have a look at the 
> varType function to determine the sub-type. varType will define the 
> exact type, there are 16 different sub-types, btw, for you. If you 
> only want to identify a few types then yopu may want to use the "is-
> functions.
> These are isDate, isArray, isNumeric, isEmpty, isNull. These only 
> return a true/false value, a boolean.
> Good luck...
Basically Colin is right about javascript and vbscript using the same 
variables, but the question was about ASP.
Now since ASP is interpreted serverside and javascript runs clientside 
(usually) you cannot use the technique that Colin suggested.
You need to pass the variable through the querystring, thus reloading 
the page and having ASP read the value through 
myVar = request.querystring("someVar")
Sorry, but there is no other way to do it.
     Nowadays, there is another choice -- AJAX:
Take care,
Dave Clark