Solved

Calling vbscript using java script.

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write 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…

739 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