Hi All,

i have this.asp page:

<script type="text/vbscript">
Function myFunc(val1ok, val2ok)
' do something ok
myFunc = " return something ok"
End Function
</script>

<html>
<body>
<%
val1ok = something1
val2ok = something2
thenewVal = myFunc((val1ok), (val2ok))
%>
</body>
</html>

i want to call and use the returned value of Function myFunc(val1ok,
val2ok) ,

without omitting the html script tags and replacing them in <% %>,

(My Question is:)

How do i call a function defined in html script tags from asp page?

Re: How do i call a function defined in html script tags from asp page? by Mike

Mike
Wed Nov 01 05:52:13 CST 2006

"thisis" <helloOne@web.de> wrote in message
news:1162381569.185529.239290@e3g2000cwe.googlegroups.com...
> Hi All,
>
> i have this.asp page:
>
> <script type="text/vbscript">
> Function myFunc(val1ok, val2ok)
> ' do something ok
> myFunc = " return something ok"
> End Function
> </script>
>
> <html>
> <body>
> <%
> val1ok = something1
> val2ok = something2
> thenewVal = myFunc((val1ok), (val2ok))
> %>
> </body>
> </html>
>
> i want to call and use the returned value of Function myFunc(val1ok,
> val2ok) ,
>
> without omitting the html script tags and replacing them in <% %>,
>
> (My Question is:)
>
> How do i call a function defined in html script tags from asp page?
>

You can't call client-side code from server-side code. Nor vice-versa.
Full stop.

--
Mike Brind



Re: How do i call a function defined in html script tags from asp page? by Tim

Tim
Wed Nov 01 07:40:41 CST 2006

"thisis" <helloOne@web.de> wrote:

>Hi All,
>
>i have this.asp page:
>
><script type="text/vbscript">
>Function myFunc(val1ok, val2ok)
>' do something ok
>myFunc = " return something ok"
>End Function
></script>
>
><html>
><body>
><%
>val1ok = something1
>val2ok = something2
>thenewVal = myFunc((val1ok), (val2ok))
>%>
></body>
></html>
>
>i want to call and use the returned value of Function myFunc(val1ok,
>val2ok) ,
>
>without omitting the html script tags and replacing them in <% %>,
>
>(My Question is:)
>
>How do i call a function defined in html script tags from asp page?

You don't. The ASP code runs on the server, producing HTML as output.
When the ASP code finishes, the resulting HTML is sent to the client.
The client's browser parses it, finding the Javascript code (among
other things). Since the server-side ASP function has finished and is
*not* sent to the client, the client-side Javascript cannot call it.
It doesn't exist any more by the time the Javascript code runs.

--
Tim Slattery
MS MVP(DTS)
Slattery_T@bls.gov

Re: How do i call a function defined in html script tags from asp page? by Anthony

Anthony
Wed Nov 01 08:50:57 CST 2006


"thisis" <helloOne@web.de> wrote in message
news:1162381569.185529.239290@e3g2000cwe.googlegroups.com...
> Hi All,
>
> i have this.asp page:
>
> <script type="text/vbscript">
> Function myFunc(val1ok, val2ok)
> ' do something ok
> myFunc = " return something ok"
> End Function
> </script>
>
> <html>
> <body>
> <%
> val1ok = something1
> val2ok = something2
> thenewVal = myFunc((val1ok), (val2ok))
> %>
> </body>
> </html>
>
> i want to call and use the returned value of Function myFunc(val1ok,
> val2ok) ,
>
> without omitting the html script tags and replacing them in <% %>,
>
> (My Question is:)
>
> How do i call a function defined in html script tags from asp page?
>

If you have a set of functions you want to share with the client and the
server place the functions in a VBS file. Take this example Test.vbs:-

Function DoSomething(a, b)
DoSomething = a + b
End Function

Note that since this is a vbs file it does not contain <%%>

Now here is an example page that consumes the function both server side and
client side:-

<script src="test.vbs" runat="server" language="vbscript"></script>
<html>
<script src="test.vbs" type="text/vbscript"></script>
<script type="text/vbscript">
Function Body_Onload()
divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
End Function
</script>
<body onload="Body_Onload()">
1 + 2 = <%=DoSomething(1,2)%>
<div id="divLocal" />
</body>
</html>

Anthony.



Re: How do i call a function defined in html script tags from asp page? by Tim

Tim
Wed Nov 01 11:13:24 CST 2006

"Anthony Jones" <Ant@yadayadayada.com> wrote:


>If you have a set of functions you want to share with the client and the
>server place the functions in a VBS file. Take this example Test.vbs:-
>
>Function DoSomething(a, b)
>DoSomething = a + b
>End Function
>
>Note that since this is a vbs file it does not contain <%%>
>
>Now here is an example page that consumes the function both server side and
>client side:-
>
><script src="test.vbs" runat="server" language="vbscript"></script>
><html>
> <script src="test.vbs" type="text/vbscript"></script>
> <script type="text/vbscript">
>Function Body_Onload()
> divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
>End Function
> </script>
> <body onload="Body_Onload()">
> 1 + 2 = <%=DoSomething(1,2)%>
> <div id="divLocal" />
> </body>
></html>

That will work, but only with IE. Anybody using FireFox, Mozilla,
Opera, Netscape, or any other non-MS browser won't be able to use the
page.

--
Tim Slattery
MS MVP(DTS)
Slattery_T@bls.gov

Re: How do i call a function defined in html script tags from asp page? by Anthony

Anthony
Wed Nov 01 16:54:20 CST 2006


"Tim Slattery" <Slattery_T@bls.gov> wrote in message
news:eblhk25hb0lok7s064eun4pjlb6t3aqmg4@4ax.com...
> "Anthony Jones" <Ant@yadayadayada.com> wrote:
>
>
> >If you have a set of functions you want to share with the client and the
> >server place the functions in a VBS file. Take this example Test.vbs:-
> >
> >Function DoSomething(a, b)
> >DoSomething = a + b
> >End Function
> >
> >Note that since this is a vbs file it does not contain <%%>
> >
> >Now here is an example page that consumes the function both server side
and
> >client side:-
> >
> ><script src="test.vbs" runat="server" language="vbscript"></script>
> ><html>
> > <script src="test.vbs" type="text/vbscript"></script>
> > <script type="text/vbscript">
> >Function Body_Onload()
> > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
> >End Function
> > </script>
> > <body onload="Body_Onload()">
> > 1 + 2 = <%=DoSomething(1,2)%>
> > <div id="divLocal" />
> > </body>
> ></html>
>
> That will work, but only with IE. Anybody using FireFox, Mozilla,
> Opera, Netscape, or any other non-MS browser won't be able to use the
> page.

True but the OP started off with VBScript already being sent to the client
as it was so clearly IE is the target.

>
> --
> Tim Slattery
> MS MVP(DTS)
> Slattery_T@bls.gov



Re: How do i call a function defined in html script tags from asp page? by thisis

thisis
Thu Nov 02 09:55:35 CST 2006


Anthony Jones wrote:
> "thisis" <helloOne@web.de> wrote in message
> news:1162381569.185529.239290@e3g2000cwe.googlegroups.com...
> > Hi All,
> >
> > i have this.asp page:
> >
> > <script type="text/vbscript">
> > Function myFunc(val1ok, val2ok)
> > ' do something ok
> > myFunc = " return something ok"
> > End Function
> > </script>
> >
> > <html>
> > <body>
> > <%
> > val1ok = something1
> > val2ok = something2
> > thenewVal = myFunc((val1ok), (val2ok))
> > %>
> > </body>
> > </html>
> >
> > i want to call and use the returned value of Function myFunc(val1ok,
> > val2ok) ,
> >
> > without omitting the html script tags and replacing them in <% %>,
> >
> > (My Question is:)
> >
> > How do i call a function defined in html script tags from asp page?
> >
>
> If you have a set of functions you want to share with the client and the
> server place the functions in a VBS file. Take this example Test.vbs:-
>
> Function DoSomething(a, b)
> DoSomething = a + b
> End Function
>
> Note that since this is a vbs file it does not contain <%%>
>
> Now here is an example page that consumes the function both server side and
> client side:-
>
> <script src="test.vbs" runat="server" language="vbscript"></script>
> <html>
> <script src="test.vbs" type="text/vbscript"></script>
> <script type="text/vbscript">
> Function Body_Onload()
> divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
> End Function
> </script>
> <body onload="Body_Onload()">
> 1 + 2 = <%=DoSomething(1,2)%>
> <div id="divLocal" />
> </body>
> </html>
>
> Anthony.

Hi Anthony Jones,

i attemped to run your sample in couple on run test combinations.

case run test 1
==============
the test.vbs:

Function DoSomething(a, b)
DoSomething = a + b
End Function

the test.asp:

1 <script src="test.vbs" runat="server" language="vbscript"></script>
2 <html>
3 <body>
4 3 + 4 = <%=DoSomething(3,4)%>
5 </body>
6 </html>

result:
3 + 4 =
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'DoSomething'
/dt/test.asp, line 4

My Question:case run test 1
it seems that the script test.vbs runs on the server,
and the the test.asp code line runs on the server too.

So, Why do I get the Type mismatch: 'DoSomething' error?


Re: How do i call a function defined in html script tags from asp page? by thisis

thisis
Thu Nov 02 10:05:37 CST 2006


Anthony Jones wrote:
> "thisis" <helloOne@web.de> wrote in message
> news:1162381569.185529.239290@e3g2000cwe.googlegroups.com...
> > Hi All,
> >
> > i have this.asp page:
> >
> > <script type="text/vbscript">
> > Function myFunc(val1ok, val2ok)
> > ' do something ok
> > myFunc = " return something ok"
> > End Function
> > </script>
> >
> > <html>
> > <body>
> > <%
> > val1ok = something1
> > val2ok = something2
> > thenewVal = myFunc((val1ok), (val2ok))
> > %>
> > </body>
> > </html>
> >
> > i want to call and use the returned value of Function myFunc(val1ok,
> > val2ok) ,
> >
> > without omitting the html script tags and replacing them in <% %>,
> >
> > (My Question is:)
> >
> > How do i call a function defined in html script tags from asp page?
> >
>
> If you have a set of functions you want to share with the client and the
> server place the functions in a VBS file. Take this example Test.vbs:-
>
> Function DoSomething(a, b)
> DoSomething = a + b
> End Function
>
> Note that since this is a vbs file it does not contain <%%>
>
> Now here is an example page that consumes the function both server side and
> client side:-
>
> <script src="test.vbs" runat="server" language="vbscript"></script>
> <html>
> <script src="test.vbs" type="text/vbscript"></script>
> <script type="text/vbscript">
> Function Body_Onload()
> divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
> End Function
> </script>
> <body onload="Body_Onload()">
> 1 + 2 = <%=DoSomething(1,2)%>
> <div id="divLocal" />
> </body>
> </html>
>
> Anthony.

Hi Anthony Jones,

i tried to run your sample code in a couple of run time test
combination.
on some cases i got errors, which i don't understand why the errors
where "produced"?

for example:

case run test 1
==============
the test.vbs:

Function DoSomething(a, b)
DoSomething = a + b
End Function

the test.asp:

1 <script src="test.vbs" runat="server" language="vbscript"></script>
2 <html>
3 <body>
4 3 + 4 = <%=DoSomething(3,4)%>
5 </body>
6 </html>

ie result:
3 + 4 =
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'DoSomething'
/dt/test.asp, line 4

My Question:case run test 1
it seems that the script test.vbs runs on the server,
because: script src="test.vbs" runat="server" ok.
and, it seems that the test.asp code line runs on the server too,
because: <% %> is in the .asp page

So, Why do I get the Type mismatch: 'DoSomething' error?


Re: How do i call a function defined in html script tags from asp page? by Anthony

Anthony
Thu Nov 02 10:29:11 CST 2006


"thisis" <helloOne@web.de> wrote in message
news:1162483537.313615.306570@h48g2000cwc.googlegroups.com...
>
> Anthony Jones wrote:
> > "thisis" <helloOne@web.de> wrote in message
> > news:1162381569.185529.239290@e3g2000cwe.googlegroups.com...
> > > Hi All,
> > >
> > > i have this.asp page:
> > >
> > > <script type="text/vbscript">
> > > Function myFunc(val1ok, val2ok)
> > > ' do something ok
> > > myFunc = " return something ok"
> > > End Function
> > > </script>
> > >
> > > <html>
> > > <body>
> > > <%
> > > val1ok = something1
> > > val2ok = something2
> > > thenewVal = myFunc((val1ok), (val2ok))
> > > %>
> > > </body>
> > > </html>
> > >
> > > i want to call and use the returned value of Function myFunc(val1ok,
> > > val2ok) ,
> > >
> > > without omitting the html script tags and replacing them in <% %>,
> > >
> > > (My Question is:)
> > >
> > > How do i call a function defined in html script tags from asp page?
> > >
> >
> > If you have a set of functions you want to share with the client and the
> > server place the functions in a VBS file. Take this example Test.vbs:-
> >
> > Function DoSomething(a, b)
> > DoSomething = a + b
> > End Function
> >
> > Note that since this is a vbs file it does not contain <%%>