Solved

Calling vbscript using java script.

Posted on 1998-12-01
4
153 Views
Last Modified: 2008-02-26
I can run javascript and vb script on the same page, and everything is functioning like I want it to, but now, I want to call one of my functions in vb by the javascript, and pass it some parameters......Is this possible..?
0
Comment
Question by:ShaunMarion
  • 3
4 Comments
 
LVL 6

Accepted Solution

by:
PBall earned 100 total points
ID: 1274861
And why not?

<html>
<head>
<script language='VBScript'>
function VBFunc1(param)
  msgbox("You entered " & param & " when calling this function (VBFunc1)")
  VBFunc1 = JSFunc2(param)
end function

function VBFunc2(param)
  msgbox("You entered " & param & " when calling this function (VBFunc2)")
  msgbox("Too much redirecting and mix languages... I am confused. I better stop now.")
  VBFunc2 = "This is the value returned from VBFunc2"
end function
</script>

<script language='JavaScript'>
function JSFunc1(param)
{
  alert("You entered " + param + " when calling this function (JSFunc1)")
  alert(VBFunc1(param))
}

function JSFunc2(param)
{
  alert("You entered " + param + " when calling this function (JSFunc2)")
  return (VBFunc2(param))
}
</script>
</head>
<body onLoad="JSFunc1('Hello, World!')">
</body>
</html>
0
 
LVL 6

Expert Comment

by:PBall
ID: 1274862
The sample in the answer demonstrate that quite well.

I was passing parameter from JSFunc1 to all other functions
and as the last trick, VBFunc2 will also pass a return value back up the chain to JSFunc1.

It's doable :-p.

0
 
LVL 6

Expert Comment

by:PBall
ID: 1274863
Hehe,

I do this all the time when some functions are just easier to do (or already built) in one or the other scripting language.  A good example for this is VBScript Date object functions (DateAdd, DateDiff, etc. etc.) which are not implemented in JavaScript (write your own if you wish).  I have to use those functions quite often, so why not mismatch the language?  Faster development time.
0
 

Author Comment

by:ShaunMarion
ID: 1274864
thanks.......
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now