PDA

View Full Version : Calling VBScript function from javascript


praveeng78
08-24-2002, 09:59 PM
I am not sure if I can call a vbscript function from within a javascript function. I am doing a quiz, the responses of which are constantly collected in an array. At the end of the quiz I want to store the responses into an Access database. For the database part I have a vbscript function. The question is whether I can call that vbscript function from the javascript function. If so what should be the format/syntax.

Dr. Web
08-24-2002, 10:45 PM
if your doing this in asp, and vbscript is your server side code of choice, there is no need to try to 'call' the script. Simply submit your form to the action.asp page and let the server side vbscript do as it is instructed.

Sounds like your caught up with trying to learn asp in a hurry. Might I suggest: ASP weekend crash course. You can find it at any major bookseller, and it will provide you with the skills you need to get the job done. Also, www.brinkser.com is a good, free ASP hosting service that offers, among other things, free access db's and tutorials in ASP and SQL.

Jon Hanlon
08-24-2002, 11:12 PM
Depends on what you mean by 'vbscript function'.
If you want to call a function or subroutine you've written in vbscript, then just invoke it from javascript:
myVBfunction();

If you want to use one of the native VB functions, like say len, or msgbox, then wrap it in your own function:

<script language="vbscript">
Function myTrim(str)
myTrim = Trim(str)
End Function
</script>

<script language="javascript">
var excessString = " Leading & Trailing Spaces "
var trimString = myTrim(excessString)
</script>