Author |
Topic  |
|
paulnoe
Starting Member
USA
48 Posts |
Posted - 13 August 2003 : 16:29:21
|
I am calling a javascript function from an asp page. The function is in a server-side include file.
The default language of the asp page that is calling the function is vbscript. For some reason, my asp page is viewing the function as a variable instead of calling the function and passing the arguments.
The code calling the function:
LoginStatus = ValidateUser(UserID, Password)
It is passing the proper values in the proper order. Any thoughts?
Thank you - Paul |
Paul Noe paul@thenoes.com |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 13 August 2003 : 18:11:41
|
afaik, you can't mix languages like that. you would need to turn the function into a vbscript function or find another creative way to do it. |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 13 August 2003 : 18:58:07
|
You can call js functions from VBS and vice-versa, and even to/from perlscript, although there are sometimes datatype problems between languages.
You have to use <script runat=server> .. </script> in your asp for code from the "foreign" language. <% %> delimeters only handle the default page language.
|
====== Doug G ====== Computer history and help at www.dougscode.com |
 |
|
D3mon
Senior Member
   
United Kingdom
1685 Posts |
Posted - 13 August 2003 : 18:59:50
|
The Javascript function won't actually exist when the ASP script is executed on the server. The ASP will send the Javascript to the browser, which will then be able to execute it later in the process, client-side.
Of course you could create server-side Javascript, but why bother when VBScript could do the job? |
 Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod "In war, the victorious strategist only seeks battle after the victory has been won" |
Edited by - D3mon on 13 August 2003 19:02:30 |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 13 August 2003 : 20:28:55
|
quote: The Javascript function won't actually exist when the ASP script is executed on the server. The ASP will send the Javascript to the browser, which will then be able to execute it later in the process, client-side.
Not really, you can write javascript to run on the server. Below is a very quick sample page that runs fine on IIS5.1
<%@ Language=VBScript %>
<%
Dim MyVar
MyVar = GetTheString("Test")
%>
<script language=javascript runat=server>
function GetTheString(ts) {
ts = ts + " more stuff";
return ts;
}
</script>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<P> </P>
The script returned <% =MyVar %>
</BODY>
</HTML>
|
====== Doug G ====== Computer history and help at www.dougscode.com |
 |
|
paulnoe
Starting Member
USA
48 Posts |
Posted - 14 August 2003 : 08:38:11
|
Thanks a bunch - I will take another look at how I'm mixing languages. I was worried about that. |
Paul Noe paul@thenoes.com |
 |
|
CarKnee
Junior Member
 
USA
297 Posts |
Posted - 14 August 2003 : 08:59:07
|
quote: Originally posted by D3mon Of course you could create server-side Javascript, but why bother when VBScript could do the job?
I thought the same thing until I wanted to use some date/time functions that do not exist in VBScript. For instance: getUTCDate() and all the other UTC date/time functions
|
 |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 14 August 2003 : 12:22:15
|
quote: Originally posted by CarKnee
quote: Originally posted by D3mon Of course you could create server-side Javascript, but why bother when VBScript could do the job?
I thought the same thing until I wanted to use some date/time functions that do not exist in VBScript. For instance: getUTCDate() and all the other UTC date/time functions
I think date/time stuff was what first got me on the js road too :)
|
====== Doug G ====== Computer history and help at www.dougscode.com |
 |
|
bjlt
Senior Member
   
1144 Posts |
Posted - 14 August 2003 : 15:34:59
|
I did the same as no function in vbs is like getUTCDate() too.
Talking about vbs and js, I've run across another asp forum application and the author said in his next release vbscript is left mainly for communication with the db only and he'll use js mostly for all other staff, accroding to him it will be more efficient. I'm not sure about the difference of efficiency and how he'd calculated it. Maybe he's talking about more client side activity as his forum does not pay much attention on cross brower support, or is js really more efficient actually? |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 14 August 2003 : 20:40:59
|
From what I've read, vbs and js are similar in performance on windows asp platforms.
|
====== Doug G ====== Computer history and help at www.dougscode.com |
 |
|
|
Topic  |
|