SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    putting asp and javascript together

    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:

    Code:
    <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:
    Code:
      //<![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?
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As ASP processes server side code first and then creates the HTML which is then rendered by the browser (which also processes the client side code), you cannot mix the asp and js code. What you can anyway do is have the same function in a VBScript function as well and call this function.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes you can use Javascript in ASP something like this:

    <%
    response.write("<SCRIPT LANGUAGE=""Javascript"">" & vbNewLine _
    & "myphone= """ & objRS("mobilephone") & """;" & vbNewLine _
    & "mycolor= ""000066"";" & vbNewLine _
    & "</script>")
    %>

  4. #4
    SitePoint Enthusiast afgmail's Avatar
    Join Date
    Jan 2005
    Location
    Houston, TX
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I could help if you were more clear on what you're trying to achieve.
    Scan completed....
    Brain not found.
    filecabin.com : Notepad2

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can write out dynamic client side JavaScript from the server side ASP.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •