Calling ASP function in Javascript
Calling ASP function in Javascript
am 19.09.2005 06:10:13 von DNKMCA
Hi,
Can i call a ASP function (with parameters) inside JavaScript. with
parameters as
JavaScript variables?
Please help in correcting the below code..
Thanks
DNK.
Code:
<%
function getUserName(byval uid)
if uid=1 then
getUserName = "ABC"
elseif uid=2 then
getUserName = "XYZ"
end if
end function
%>
Re: Calling ASP function in Javascript
am 19.09.2005 06:45:21 von Roland Hall
"DNKMCA" wrote in message news:uYuGIANvFHA.2076@TK2MSFTNGP14.phx.gbl...
: Can i call a ASP function (with parameters) inside JavaScript. with
: parameters as
: JavaScript variables?
: Please help in correcting the below code..
:
: Thanks
: DNK.
:
:
: Code:
:
: <%
: function getUserName(byval uid)
:
: if uid=1 then
: getUserName = "ABC"
: elseif uid=2 then
: getUserName = "XYZ"
: end if
:
: end function
:
: %>
:
:
It doesn't work like that. Server-side script runs before client-side.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Re: Calling ASP function in Javascript
am 19.09.2005 10:06:06 von exjxw.hannivoort
DNKMCA wrote on 19 sep 2005 in microsoft.public.inetserver.asp.db:
> Can i call a ASP function (with parameters) inside JavaScript.
Dubious question:
ASP is not a language, so does not implicitly mean VBscript.
Javascript does not implicitly mean clientside script.
Yes,
you can call a serverside ASP function,
written in either vbs or js,
by serverside js.
No,
you cannot call a serverside function in a clientside script,
or use a clientside variable in a serverside function.
=================
> var uid = document.chk.userid.value;
> var found = "<%=getUserName(" + uid + ")%>"
Yes, you can do this clientside javascript:
var found = '<%=getUserName("12")%>';
Buy no, not this:
var uid = '12';
var found = '<%=getUserName(" + uid + ")%>';
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Re: Calling ASP function in Javascript
am 19.09.2005 15:54:06 von Roland Hall
"Evertjan." wrote in message news:Xns96D666C33F16Feejj99@194.109.133.242...
: DNKMCA wrote on 19 sep 2005 in microsoft.public.inetserver.asp.db:
:
: > Can i call a ASP function (with parameters) inside JavaScript.
:
: Dubious question:
:
: ASP is not a language, so does not implicitly mean VBscript.
: Javascript does not implicitly mean clientside script.
:
: Yes,
: you can call a serverside ASP function,
: written in either vbs or js,
: by serverside js.
:
: No,
: you cannot call a serverside function in a clientside script,
: or use a clientside variable in a serverside function.
:
: =================
:
: > var uid = document.chk.userid.value;
: > var found = "<%=getUserName(" + uid + ")%>"
:
: Yes, you can do this clientside javascript:
:
: var found = '<%=getUserName("12")%>';
:
: Buy no, not this:
:
: var uid = '12';
: var found = '<%=getUserName(" + uid + ")%>';
However, you could use remote scripting as I have done here:
http://kiddanger.com/lab/ee/q_21539292.asp
It makes and HTTPRequest to an ASP page to get information from a database
and return the results.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Re: Calling ASP function in Javascript
am 19.09.2005 16:57:41 von exjxw.hannivoort
Roland Hall wrote on 19 sep 2005 in microsoft.public.inetserver.asp.db:
> "Evertjan." wrote in message
[...]
>: Buy no, not this:
>:
>: var uid = '12';
>: var found = '<%=getUserName(" + uid + ")%>';
>
> However, you could use remote scripting as I have done here:
> http://kiddanger.com/lab/ee/q_21539292.asp
>
> It makes and HTTPRequest to an ASP page to get information from a
> database and return the results.
But, Roland, that only confuses the level of the OQ,
and has nothing to do with the script above, provided by the OP.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Re: Calling ASP function in Javascript
am 20.09.2005 15:41:38 von middletree
> However, you could use remote scripting as I have done here:
> http://kiddanger.com/lab/ee/q_21539292.asp
What, exactly, is the desired effect here? I click on any of the choices,
and nothing happens. At least, nothing I can see.
Re: Calling ASP function in Javascript
am 21.09.2005 09:57:42 von Roland Hall
"middletree" wrote in message news:uSdgAlevFHA.1168@TK2MSFTNGP10.phx.gbl...
:> However, you could use remote scripting as I have done here:
: > http://kiddanger.com/lab/ee/q_21539292.asp
:
: What, exactly, is the desired effect here? I click on any of the choices,
: and nothing happens. At least, nothing I can see.
You must be using Firefox. Try this instead:
http://kiddanger.com/lab/httprequest.html
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Re: Calling ASP function in Javascript
am 21.09.2005 14:54:28 von middletree
>
> You must be using Firefox. Try this instead:
> http://kiddanger.com/lab/httprequest.html
Yes, I was using FF. I went back and used IE, and saw the desired effect.
Perhaps the poster should have said something about his code only working in
IE.
Re: Calling ASP function in Javascript
am 21.09.2005 15:00:08 von middletree
Just started looking at the code, and it's pretty neat. Even though it may
or may not have been an answer to the OP, I'm finding it educational. Thanks
for sharing.
I still don't get how it works even when I have it running from my hard
drive, but I will analyze it some more and try to figure it out.
Re: Calling ASP function in Javascript
am 30.09.2005 23:31:26 von Roland Hall
"middletree" wrote in message news:uolxbyqvFHA.2292@TK2MSFTNGP12.phx.gbl...
: Just started looking at the code, and it's pretty neat. Even though it may
: or may not have been an answer to the OP, I'm finding it educational.
Thanks
: for sharing.
:
: I still don't get how it works even when I have it running from my hard
: drive, but I will analyze it some more and try to figure it out.
The OP wanted to call for ASP variables from client-side and that's not
possible. However, using remote scripting you can effectively post to an
ASP page, return the result and grab that from the client-side script, which
is what I'm showing how to do. The ASP page posts and returns a result but
the user never sees that happen nor do they see the page refresh because it
is the ASP page that does the work.
It allows the user to grab an ASP variable value and use it in their current
script without refreshing or posting directly from that page.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp