Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling vbscript from javascript...help !!!!!!

Status
Not open for further replies.

charlesb

IS-IT--Management
Dec 14, 2001
26
GB
I have looked at other questions posted about this subject.
I have taken the suggested code and placed it into a page and it all works wonderfully.

However, when I include this in a page generated by Ultradev as a function the VBscript function when called froma Javascript function is either ignored or said not to be defined.

Ultradev generates vbscript with <@language=&quot;vbscript&quot;> and then <% %> used to delimit where vbscript is used.

However the code I had found and used above seems to need <script LANGUAGE=&quot;VBSCRIPT&quot;> </script>.


I know this is a stupid question but what is the difference between <@language=&quot;vbscript&quot;> and <script LANGUAGE=&quot;VBSCRIPT&quot;> ..... client and server side ?

If I try to put the function within the <script version then all my instructions that seem fine within <% now seem to have invalid syntax.

My basic requirement is within my Javascript validation function I wish to call a vbscript function (which accesses data files). Its not much to ask ... I need very little in life... just an answer to this idiot question.

If you cab help please make this very frustrated person very happy.

Thanks



 
<% @language=&quot;VBSCRIPT&quot; %> means that everything inside <% %> tags is server side scripting, and the language will be VBScript. Anything inside <script language=&quot;&quot;> </script> tags is client side. Client side scripting and server side scripting cannot communicate at all. Server side scripting is for building the pages, and is completely finished before the end user sees the entire page, so can't even see client side scripts or functions. Server side scripting is run from the server (obviously), while client side is run on a completely different computer. Client side scripting never sees server side functions or anything else related to the server side scripts.

Server side scripts are for building the page dynamically from the server, and client side scripts are for interacting with the page from the end user's computer. You can write information inside client side scripts with server side scripting, like:

var clientvariable=<%servervariable%>

but that's all you can do to get the 2 to interact.
 
Maybe I have misunderstood your question but are you just trying to call a VBScript routine from JavaScript ?

<% @language=&quot;VBSCRIPT&quot; %>
<Body onLoad=&quot;My_JavaScript();&quot;>

<% 'this would only run from server ignored by client%>
<% 'But client side scripts below will work %>

</Body>

<script language=&quot;javaScript&quot;>
//Client side
function My_JavaScript()
{
My_VBScript(); //calls VBScript
}
</script>

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!-- Client Side
sub My_VBScript()
Msgbox &quot;I was called from a JavaScript Function&quot;
End Sub
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top