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


gilgalbiblewhee
04-05-2005, 08:35 PM
I have a database table where I managed to add with ASP an extra column which breaks down the previous column "text_data" and counts the number of words:


<td>
<% Dim TheString, ArrayTemp, NumberOfWords, Word
TheString = rs("text_data")
ArrayTemp = split(TheString, " ")
NumberOfWords = UBound(ArrayTemp) + 1
' Response.Write "<P>The String is: " & TheString
Response.Write "<P>Number of words: " & NumberOfWords
' Response.Write "<P>Here are the words which compose that string: "
For Each Word In ArrayTemp
Response.Write "<BR><font size=""5"" face=""BSTHebrew"">" & word & "</font> = "
next%>

</td>


My goal is to take each letter and assign them to a number:
a=1,b=2...
Which I have done in another place with JavaScript:

//<![CDATA[
//&&& 1st of 2 instances of getKeyValue(). changed name of Fx, '_h' for hebrew?
function getKeyValue_h(chr) {
//A switch statement is more efficient for this
switch(chr.charAt()){
case "a": return 1;
case "b": return 2;
case "g": return 3;
case "d": return 4;
case "h": return 5;
case "w": return 6;
case "x": return 8;
case "j": return 9;
case "y": return 10;
case "k":;
case "$": return 20;
case "l": return 30;
case "m":;
case "~": return 40;
case "n":;
case "!": return 50;
case "s": return 60;
case "[": return 70;
case "p":;
case "@": return 80;
case "c":;
case "#": return 90;
case "q": return 100;
case "r": return 200;
case "f":;
case "v": return 300;
case "t": return 400;
default: return 0;
}
}

function computeValue(str) {
var ans = 0;
for(var i = 0; i < str.length; i++) {
ans += getKeyValue_h(str.charAt(i));
}
return ans;
}
//]]>


The JavaScript was for a textbox object and textarea. Is there a way to calculate (add) the numbers of the letters assigned after each " = " in the ASP code?

Olórin
04-06-2005, 12:39 AM
The problem is that you are talking about two different things. ASP is server level and javascript is client based. Your talking about taking information from your page that your javascript created and then having some vbscript code do something with it. This means you will have to setup your javascript code to setup you data on your page as form information and then have it posted to an ASP page. Lots of work there.

What are you trying to accomplish? There might be an easier way.

For more info about Javascript and VBScript/ASP look here,

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=169

Hope this helps

- Olórin