Click to See Complete Forum and Search --> : Convert javascript to asp


TroelsM
06-06-2004, 05:51 AM
HI there !
I have the following code
function CryptMailto(s) {
var n=0;
var r="";
for(var i=0;i<s.length;i++) {
n=s.charCodeAt(i);
if (n>=8364) {n = 128;}
r += String.fromCharCode(n+(2));
}
return r;
}

can some one translate that to ASP ?
It takes all char and move it 2 places - som abc would bee to cde

Alex C
06-07-2004, 02:20 AM
Here you go, From your Javascript to this ASP.

<%@ LANGUAGE="JScript" %>

<%

function CryptMailto(s) {
var n=0;
var r="";
for(var i=0;i<s.length;i++) {
n=s.charCodeAt(i);
if (n>=8364) {n = 128;}
r += String.fromCharCode(n+(2));
}
return r;
}

%>

TroelsM
06-07-2004, 03:42 PM
Tx Alex C

The solution you wrote is almost the one that I came to use,
se here
http://www.webdeveloper.com/forum/showthread.php?s=&postid=199442#post199442

I needed a littel trick to call the function and get the result back to the page but made this by a second function.