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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hmmmm. dont know what to call this

Status
Not open for further replies.

UnfitElf

Programmer
Dec 3, 2002
24
NZ
Hi all...

I have just started to have a bit of fun with vbscript on the client. I want to call a function or a bit of vbscript code from my asp code.

an example would be to say

if request("BUTTON")="Submit" Then
'i want to call the client vbscript code here

how would i do this??

Thanks in advance
 
You can't call client-side script directly from server-side script. You can do the following, at best:
Code:
<% @Language=VBScript %>
<html>
<head>
</head>
<body>
<script language=&quot;JavaScript&quot;>
<%
If Request(&quot;BUTTON&quot;)=&quot;Submit&quot; Then
Response.Write(&quot;MyFunction();&quot;)
End If
%>
</script>
</body>
</html>

The above will have the returned page call the function
Code:
MyFunction()
as soon as the page is loaded in the client's browser. That is as soon as you can call a client-side function. Note: I used JavaScript here because I don't use client-side VBScript myself.
 
Oops... of course the code above should have the function MyFunction() actually defined in the client-side script block...
Code:
<% @Language=VBScript %>
<html>
<head>
</head>
<body>
<script language=&quot;JavaScript&quot;>
<%
If Request(&quot;BUTTON&quot;)=&quot;Submit&quot; Then
Response.Write(&quot;MyFunction();&quot;)
End If
%>
function MyFunction()
{
alert('hello world!');
}
</script>
</body>
</html>
 
oh...

i see..

thanks for that :)

That Helps HEAPS..

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top