Solved

Calling vbscript using java script.

Posted on 1998-12-01
4
154 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

896 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

13 Experts available now in Live!

Get 1:1 Help Now