Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do I call a VB button script from my custom javascript button?

Posted on 2007-10-07
6
Medium Priority
?
220 Views
Last Modified: 2008-01-09
How do I call a VB button script from my custom javascript button?

1.) The VB script:
<SCRIPT LANGUAGE=VBScript>
Sub Btn1_onclick()
     MsgBox("Got it!")
End Sub
</SCRIPT>

2.) The normal button call that works
<INPUT TYPE=BUTTON NAME=Btn1 VALUE="Print Labels">

3.) My custom button with the "unknown syntax":
<table class="t15Button" cellspacing="0" cellpadding="0" border="0"  summary=""><tr>
<td class="t15L"><img src="/i/themes/theme_15/button-l.gif" alt="" /></td>
<td class="t15C"><a href="javascript:          unknown syntax           ;">Print Labels</a></td>
<td class="t15R"><img src="/i/themes/theme_15/button-r.gif" alt="" /></td>
</tr></table>

Thank you, Bill
0
Comment
Question by:bcarlis
6 Comments
 
LVL 16

Accepted Solution

by:
Kiran Paul VJ earned 1000 total points
ID: 20030507
try this
<table class="t15Button" cellspacing="0" cellpadding="0" border="0"  summary=""><tr>
<td class="t15L"><img src="/i/themes/theme_15/button-l.gif" alt="" /></td>
<td class="t15C"><a href="#" onclick="Btn1_onclick()">Print Labels</a></td>
<td class="t15R"><img src="/i/themes/theme_15/button-r.gif" alt="" /></td>
</tr></table>
0
 
LVL 16

Expert Comment

by:Kiran Paul VJ
ID: 20030516
how to call vbscript from javascript

<html>
<head>
<title>Untitled</title>
</head>
<body>
<SCRIPT LANGUAGE="VBSCRIPT">
Function returnValue()
returnValue = "Hello, world!"
End Function
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function getVBValue(){
var vbval = returnValue();
alert("VBScript value = " + vbval);
}
getVBValue();
</SCRIPT>
</body>
</html>
0
 
LVL 16

Expert Comment

by:Kiran Paul VJ
ID: 20030527
or you can try this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<SCRIPT LANGUAGE=VBScript>
Sub Btn1_onclick()
     MsgBox("Got it!")
End Sub
</SCRIPT>

<script language="javascript">
function CallVBScript(functionName)
{
      eval(functionName);
}
</script>
</head>

<body>
<table class="t15Button" cellspacing="0" cellpadding="0" border="0"  summary=""><tr>
<td class="t15L"><img src="/i/themes/theme_15/button-l.gif" alt="" /></td>
<td class="t15C"><a href="javascript:CallVBScript('Btn1_onclick()');">Print Labels</a></td>
<td class="t15R"><img src="/i/themes/theme_15/button-r.gif" alt="" /></td>
</tr></table>

</body>
</html>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 17

Expert Comment

by:gops1
ID: 20030554
Make it as a function:

<html>
      <head>
            <title>Script Demo</title>
            <script type="text/vbscript">
                  function Btn1_onclick()
                        MsgBox "Got it!"
                  end function

            </script>
      </head>
<body>
      <table class="t15Button" cellspacing="0" cellpadding="0" border="0"  summary="">
            <tr>
                  <td class="t15L"><img src="/i/themes/theme_15/button-l.gif" alt="" /></td>
                  <td class="t15C"><a href="vbscript:Btn1_onclick()">Print Labels</a></td>
                  <td class="t15R"><img src="/i/themes/theme_15/button-r.gif" alt="" /></td>
            </tr>
      </table>


</body>
</html>
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20031099
I think gops1 has it right there.  The main difference is that you have to use the "vbscript" before the function name, so the code knows which language the function is, that you are calling.  If you specify "javascript", but it is a "vbscript" function, you will get the syntax error.

Regards,

Rob.
0
 
LVL 2

Author Comment

by:bcarlis
ID: 20032133
That's the one that worked!

Thank you all for your input!
Bill
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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…
Suggested Courses

581 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