Click to See Complete Forum and Search --> : How to call a JavaScript from VBScript?


aadaileh
11-25-2004, 06:39 AM
Hi Guys,

I have to use a JavaScript and VBScript in the same page. In the way that VBScript is calling a JavaScript.

Can anybody tell me how to call a javascript from a vbscript?

Thanx,
Ahmed

matt.carter.25
11-25-2004, 11:10 AM
You cant call VBScript from javascript,

VBscript is processed by the server before the page is sent, javascript works in the browser when its being viewed.

If you need values from txt fields ect the you have to create a form and submit the information back to the server to be processed.

Probably best to learn a bit more about server side code and client side code.

Matt

Warren86
11-25-2004, 11:29 AM
You can call a JS function from within a VB function or Sub.

<Script Language=JavaScript>
function something(){
alert("hello")
}
</Script>

<Script Language=VBScript>
Function anyThing()
something()
End Function
</Script>

sciguyryan
11-25-2004, 11:34 AM
Hmm, thats an interesting thing to know, thanks :D



RyanJ

matt.carter.25
11-25-2004, 11:35 AM
I think what he is tring to ask is if he can call vb function using JS

96turnerri
11-25-2004, 11:45 AM
yes he was, which cannot be done

Warren86
11-25-2004, 01:26 PM
Yes, it can.

<HTML>
<Head>
<Script Language=JavaScript>

function callVB(){

VBFunction();

}

</Script>
<Script Language=VBScript>

Function VBFunction()

MsgBox "Hello"

End Function


</Script>
<Body>
<input type=button value="Call VB" onclick="callVB()">
</Body>
</HTML>

Exuro
11-25-2004, 02:15 PM
You do know that VBScript is an IE-only scripting language, correct? Almost anything that can be done in VBScript can be done in JavaScript, and JavaScript has many options that VBScript does not. By using VBScript you're making your site inaccessible to over 20% of the web community&mdash;everyone that doesn't use Internet Explorer (statistic from W3Schools (http://www.w3schools.com/browsers/browsers_stats.asp).

matt.carter.25
11-26-2004, 02:51 AM
Ah very interesting,
Didnt know that, I hold my hand up for being wrong!

aadaileh
11-26-2004, 03:13 AM
Hi guys,

Thanx alot for the help :D

I am really thankful for this great forum.

Regards,
Ahmed