dcsimg
www.webdeveloper.com
Results 1 to 11 of 11

Thread: How to call a JavaScript from VBScript?

  1. #1
    Join Date
    Jan 2004
    Posts
    8

    How to call a JavaScript from VBScript?

    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

  2. #2
    Join Date
    Sep 2004
    Location
    London
    Posts
    43
    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
    Last edited by matt.carter.25; 11-25-2004 at 12:16 PM.

  3. #3
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    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>

  4. #4
    Join Date
    Jul 2003
    Location
    Wales
    Posts
    1,382
    Hmm, thats an interesting thing to know, thanks



    RyanJ

  5. #5
    Join Date
    Sep 2004
    Location
    London
    Posts
    43
    I think what he is tring to ask is if he can call vb function using JS

  6. #6
    Join Date
    Sep 2003
    Location
    Portsmouth, UK Occupation: Web Developer
    Posts
    2,602
    yes he was, which cannot be done

  7. #7
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    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>

  8. #8
    Join Date
    Dec 2002
    Location
    Taiwan
    Posts
    1,297
    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.

  9. #9
    Join Date
    Sep 2004
    Location
    London
    Posts
    43
    Ah very interesting,
    Didnt know that, I hold my hand up for being wrong!

  10. #10
    Join Date
    Jan 2004
    Posts
    8
    Hi guys,

    Thanx alot for the help

    I am really thankful for this great forum.

    Regards,
    Ahmed

  11. #11
    Join Date
    Aug 2012
    Posts
    1
    Quote Originally Posted by Exuro View Post
    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.
    You're right about that.

    But, there are things you can do with VBscript that you cannot with Javascript: getting data out of office files. Like for example: connecting with excel files, navigating through cells and it's values.

    That way, you could use an excel file or an access file as a database.

    If you have an intraweb in your company, and you're all working with internet explorer, then you could make a guestbook based on excel for example.

    It shouldn't be that way, the normal way is that you work with an all browser compatible system, php server and an SQL database. But aside that, other solutions still exist.

    Right here a nice example:
    http://bulevardi.be/?content=scripting&example=exvb2

    And right here you'll find nice examples to combine javascript and vbscript:
    http://bulevardi.be/?content=scripting&example=exvb1


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles