In ASP you can call a VBScript procedure from a JavaScript and vice versa.
A D V E R T I S E M E N T
ASP Code:Procedures
<html>
<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>
<body>
<p>
You can call a procedure like this:
</p>
<p>
Result: <%call vbproc(4,5)%>
</p>
<p>
Or, like this:
</p>
<p>
Result: <%vbproc 4,5%>
</p>
</body>
</html>
O/P:
You can call a procedure like this:
Result: 20
Or, like this:
Result: 20
ASP Procedures using JavaScript
To write procedures or functions in another scripting language than default,insert the <%@ language="language" %> line above the <html> tag
When calling a JavaScript or a VBScript procedure from an ASP file written in VBScript, you can use the "call" keyword followed by the procedure name.
When using the "call" keyword,if a procedure requires parameters, the parameter list must be enclosed in parentheses .
If you omit the "call" keyword, the parameter list must not be enclosed in parentheses. The parentheses are optional,if the procedure has no parameters,
When calling a VBScript or a JavaScript procedure from an ASP file written in JavaScript, always use parentheses after the procedure name.
ASP Procedure Using Both VbScript And JavaScript
<html>
<head>
<%
sub vbproc(num1,num2)
Response.Write(num1*num2)
end sub
%>
<script language="javascript" runat="server">
function jsproc(num1,num2)
{
Response.Write(num1*num2)
}
</script>
</head>
<body>
<p>Result: <%call vbproc(5,4)%></p>
<p>Result: <%call jsproc(5,4)%></p>
</body>
</html>