Urgent !!!  On server side, call javascript from vb script.

Posted on 2006-05-15
Last Modified: 2009-07-29
Hi All,

I have server side javascript and vb script, while executing my page i have to call javascript function form vb script code and manuplate the display with the returned value.

Help me as this is an urgent.

Amit Jain

Question by:amit1978
    LVL 22

    Expert Comment

    by:Ivo Stoykov
    Hello amit1978,

    this just an idea

    <%@ Language="VBScript"%>
    Sub myVB_Sub
    End Sub
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    <SCRIPT LANGUAGE="JavaScript">
    var myStrVar = '<%=myVB_Sub%>'; // if return value is string and
    var myNumVar = <%=myVB_Sub%>; // if return value is number



    LVL 5

    Author Comment


    But here we are calling vb script function thats ok, but my problem is......
    Default language of my page is vbscript, and i have to call javascript function from the page. Where vbscript and javascript both are server side language.

    Amit Jain
    LVL 22

    Accepted Solution

    Hi amit1978,

    you can use only one language...


    LVL 22

    Expert Comment

    by:Ivo Stoykov
    Hi amit1978,

    You could use Server.Transfer... to implement both languages into two different pages which will be executed and one streem.


    LVL 12

    Assisted Solution

    amit.... unless you compile the code into .dll files.... AFAIK they are not interoperable

    hence if you started /inheritedin JScript... you will have to continue in JScritp

    LVL 16

    Assisted Solution

    like the others said, you can't run javascript and ASP at the same time. Server scripting will always run before client scripting.
    The closest you can come to doing that is calling a javascript FROM vbscript:

    If Request("Submit") Then
    <Script language="Javascript">
    alert("Form has been submitted!");
    <% End If %>

    Or call a function passing an ASP value...

    <a href="##" onclick="javaFunction("<%=myASPvariable%>");">Click ME</a>

    Or BUILD a Javascript function using VBScript..

    <script LANGUAGE="JavaScript">

    function displayStuff(funnyValue)

      response.write " if (funnyValue == 'happy') "
         response.write " alert(funnyValue); "
      response.write " else "
      response.write " alert('booo');"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    737 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

    21 Experts available now in Live!

    Get 1:1 Help Now