Running a JavaScript function server-side

  • Thread starter David C. Holley
  • Start date
D

David C. Holley

How would I run a JavaScript function in a *.asp page and then pass the
value returned to VBScript for further processing? ***Converting the
function to VBScript is *NOT* an option.
 
A

Aaron Bertrand [MVP]

A *client-side* JavaScript function? You can't do that in a single load of
an ASP page. You would have to submit a form or redirect or something along
those lines. Here is the order of operations:

(a) browser requests ASP page

(b) server-side code runs

(c) client-side code runs (at this point, there is nothing left but HTML; no
server-side functions, no access to server-side databases, no ability to set
session variables, etc)

See http://www.aspfaq.com/2281 for some workarounds (this revolves around
setting session variables, but you could use it to do any further
server-side processing). Note that anything you do on the server (e.g. set
a session variable) is not available until you request another ASP page,
because of the order of operations described above. The current ASP page
simply does not contain any ASP by the time an end user can interact with
the client-side script.
 
D

David Holley

Let me restate that...

How would I run a JavaScript function SERVER-SIDE in a *.asp page and
then pass the value returned to VBScript for further processing?
***Converting the function to VBScript is *NOT* an option.

I seem to recall seeing that a *.asp can execute JavaScript. If I'm not
mistaken.
 
B

Bob Barrows [MVP]

David said:
Let me restate that...

How would I run a JavaScript function SERVER-SIDE in a *.asp page and
then pass the value returned to VBScript for further processing?

Create a server-side javascript script block in which you place your
javascript function. then call the function from your server-side vbscript
script block.

There is an article at www.aspfaq.com about doing this, but I don't have
time to search for it right now, so I suggest you do so.
***Converting the function to VBScript is *NOT* an option.
I seem to recall seeing that a *.asp can execute JavaScript. If I'm
not mistaken.

You're not mistaken: ASP supports both vbscript and
jscript/javasctipt/ECMAscript


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

No members online now.

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,382
Latest member
MichaleStr

Latest Threads

Top