?
Solved

Calling vbscript using java script.

Posted on 1998-12-01
4
Medium Priority
?
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 6

Accepted Solution

by:
PBall earned 400 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses

762 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