SitePoint Sponsor

User Tag List

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

    JavaScript: what is the function of "length" in this case?

    Because the error says "null or not an object".
    Code:
    <!-- //
    conv_tbl = [
      63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
      63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
      32,  33,8704, 1513,1505,  37,  83,8717,  65, 79,  8727, 1496,  44,8722,  58,  47,
      48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  46,  59,  60,  61,  62,  63,
      64, 1488, 1489, 1510, 1491, 69, 70, 1490, 1492, 73, 74, 1499, 1500, 1502, 1504, 1506,
      1508, 81, 1512, 1513, 1514, 85, 1493, 87, 1495, 1497, 90, 91, 92,  93, 94,  95,
      63, 97, 66, 1509, 68, 101, 102, 71, 72, 105, 106, 1498, 1500, 1501, 1503, 111,
      1507, 1511, 82, 8707, 84, 117, 118, 86, 88, 89, 1494, 123, 124, 125, 126,  63,
      63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
      63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
      63, 978,8242,8804,8260,8734, 402,9827,9830,9829,9824,8596,8592,8593,8594,8595,
      63, 177,8243,8805, 215,8733,8706,8729, 247,8800,8801,8776,8230,  63,  63,8629,
      8501,8465,8476,8472,8855,8853,8709,8745,8746,8835,8839,8836,8834,8838,8712,8713,
      8736,8711, 174, 169,8482,8719,8730,8901, 172,8743,8744,8660,8656,8657,8658,8659,
      9674,9001, 174, 169,8482,8721,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63,
      63,9002,8747,8992,  63,8993,  63,  63,  63,  63,  63,  63,  63,  63,  63,  63
    ];
    
    function convert(mc, unic_textarea)
    {
       unic = '';
    
       for (i = 0; i < mc.length; i++)
       {
          tbl_idx = mc.charCodeAt(i);
          code    = tbl_idx < conv_tbl.length ? conv_tbl[tbl_idx] : 63;
          unic    = unic + String.fromCharCode(code)
       }
    
       unic_textarea.value = unic;
    }
    
    function mc2unic()
    {
       mc = document.conv_form.mc_code.value;
       convert(mc, document.conv_form.unic_area);
    }
    
    // -->
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    SitePoint Evangelist pip's Avatar
    Join Date
    Jun 2001
    Location
    Cape Town, South Africa
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't fully understand mun! What is "document.conv_form.mc_code.value"? I need to see this, becuase that's what you're setting mc to, and that's what it complains about not finding. I also need to see what "document.conv_form.unic_area" is.

    If you could post some more of your code, or alternatively point me to the page, I could try and check it out for ya. Not like this though... it's like looking at the cover of a book and trying to understand the story without reading one page.
    - Pip
    ---------------------------------------------------------------------------------
    Nothing takes the taste out of peanut butter quite like unrequited love.

  3. #3
    SitePoint Addict
    Join Date
    May 2004
    Location
    Europe
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
     8501,8465,8476,8472,8855,8853,8709,8745,8746,8835,8839,8836,8834,8838,8712,871  3,
    You have some spaces between '871' and '3' at the end of the line.

  4. #4
    SitePoint Evangelist pip's Avatar
    Join Date
    Jun 2001
    Location
    Cape Town, South Africa
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep... that does appear to solve the problem, though I still have no clue as to what we're converting, at least I don't get any JavaScript errors when I execute this code.

    - Pip
    ---------------------------------------------------------------------------------
    Nothing takes the taste out of peanut butter quite like unrequited love.

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

    here's the code

    871 3 is supposed to be 8713. I got that because I was putting my question together on notepad. But that's not the problem.

    This was the original coding:



    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    
    <head>
    
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
    
    <title>Michigan-Claremont Hebrew Encoding to Unicode Converter</title>                                         
    
     
    
    <script type="text/javascript" language="JavaScript1.3">
    
     
    
    <!-- //
    
    conv_tbl = [
    
    63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    32, 33,8704, 1513,1505, 37, 83,8717, 65, 79, 8727, 1496, 44,8722, 58, 47,
    
    48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 46, 59, 60, 61, 62, 63,
    
    64, 1488, 1489, 1510, 1491, 69, 70, 1490, 1492, 73, 74, 1499, 1500, 1502, 1504, 1506,
    
    1508, 81, 1512, 1513, 1514, 85, 1493, 87, 1495, 1497, 90, 91, 92, 93, 94, 95,
    
    63, 97, 66, 1509, 68, 101, 102, 71, 72, 105, 106, 1498, 1500, 1501, 1503, 111,
    
    1507, 1511, 82, 8707, 84, 117, 118, 86, 88, 89, 1494, 123, 124, 125, 126, 63,
    
    63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    63, 978,8242,8804,8260,8734, 402,9827,9830,9829,9824,8596,8592,8593,8594,8595,
    
    63, 177,8243,8805, 215,8733,8706,8729, 247,8800,8801,8776,8230, 63, 63,8629,
    
    8501,8465,8476,8472,8855,8853,8709,8745,8746,8835,8839,8836,8834,8838,8712,8713,
    
    8736,8711, 174, 169,8482,8719,8730,8901, 172,8743,8744,8660,8656,8657,8658,8659,
    
    9674,9001, 174, 169,8482,8721, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    63,9002,8747,8992, 63,8993, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63
    
    ];
    
     
    
    function convert(mc, unic_textarea, html_textarea)
    
    {
    
    unic = '';
    
    html = '';
    
     
    
    for (i = 0; i < mc.length; i++)
    
    {
    
         tbl_idx = mc.charCodeAt(i);
    
         code    = tbl_idx < conv_tbl.length ? conv_tbl[tbl_idx] : 63;
    
         unic    = unic + String.fromCharCode(code);
    
         html    = html + '&#' + code + ';'
    
    }
    
     
    
    unic_textarea.value = unic;
    
    html_textarea.value = html;
    
    }
    
     
    
    function mc2unic()
    
    {
    
    mc = document.conv_form.mc_code.value;
    
    convert(mc, document.conv_form.unic_area, document.conv_form.html_area);
    
    }
    
     
    
    // -->
    
     
    
    </script> 
    
     
    
    <style type="TEXT/CSS">
    
    <!--
    
    .onLoad {
    
    color:khaki;
    
    background:black;
    
    scrollbar-base-color:darkgrey;
    
    }
    
     
    
    .onMouseOver {
    
    color:khaki;
    
    background:black;
    
    scrollbar-base-color:grey;
    
    }
    
     
    
    .onMouseOut {
    
    color:khaki;
    
    background:black;
    
    scrollbar-base-color:grey;
    
    }
    
     
    
    //-->
    
    </style>
    
     
    
    </head>
    
    <body bgcolor="black" text="khaki" link="yellow" vlink="white" alink="orange">
    
    <!-- START HOME FREE HEADER CODE -->
    
     
    
    </div>
    
    </title>
    
     
    
    <br>             
    
    <!-- END HOME FREE HEADER CODE -->
    
     
    
     
    
    <center>                         
    
    <h1>Michigan-Claremont Hebrew Encoding to Unicode Converter</h1>
    
    </center>
    
     
    
    <form name="conv_form">                                                 
    
    <center>
    
    <table border=0 cellspacing=10 cellpadding=10 align=center>
    
    <tr>
    
    <td>
    
    <center><b>Codes:</b></center><br>
    
    <table border = 1 align=top cellspacing=2 cellpadding=2>
    
    <tr>
    
    <td align=center>
    
    A = &#1488<br>
    
    </td>
    
    <td align=center>
    
    M = &#1502<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    B = &#1489<br>
    
    </td>
    
    <td align=center>
    
    n = &#1504<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    G = &#1490<br>
    
    </td>
    
    <td align=center>
    
    N = &#1503<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    D = &#1491<br>
    
    </td>
    
    <td align=center>
    
    $ = &#1505<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    H = &#1492<br>
    
    </td>
    
    <td align=center>
    
    O = &#1506<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    V = &#1493<br>
    
    </td>
    
    <td align=center>
    
    p = &#1508<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    Z = &#1494<br>
    
    </td>
    
    <td align=center>
    
    P = &#1507<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    X = &#1495<br>
    
    </td>
    
    <td align=center>
    
    c = &#1510<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    + = &#1496<br>
    
    </td>
    
    <td align=center>
    
    C = &#1509<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    Y = &#1497<br>
    
    </td>
    
    <td align=center>
    
    q = &#1511<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    k = &#1499<br>
    
    </td>
    
    <td align=center>
    
    R = &#82<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    K = &#1498<br>
    
    </td>
    
    <td align=center>
    
    S = &#1513<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    L = &#1500<br>
    
    </td>
    
    <td align=center>
    
    T = &#1514<br>
    
    </td>
    
    </tr>
    
    <tr>
    
    <td align=center>
    
    m = &#1501<br>
    
    </td>
    
    <td align=center>
    
    . = &#58<br>
    
    </td>
    
    </tr>
    
    </table>
    
    </td>
    
    <td>
    
    <h4>MC Codes</h4>
    
                     <textarea name="mc_code" rows="3" cols="64"
    
    class="onLoad" onmouseover="this.className='onMouseOver'"
    
    onmouseout="this.className='onMouseOut'"></textarea> <br>
    
     
    
    <h4>Unicode</h4>
    
                     <textarea name="unic_area" rows="3" cols="64"
    
    class="onLoad" onmouseover="this.className='onMouseOver'"
    
    onmouseout="this.className='onMouseOut'"></textarea> <br>
    
    <h4>HTML4.x</h4>
    
                     <textarea name="html_area" rows="3" cols="64"
    
    class="onLoad" onmouseover="this.className='onMouseOver'"
    
    onmouseout="this.className='onMouseOut'"></textarea> <br>
    
    <br>
    
     
    
    <center> <input name="convert" type="button" value="Convert" onclick="mc2unic()"></center>
    
     
    
    </center></form></td></table></body></html>


    But I had to change it to somehow make it fit for my database recordset. (I use ASP)



    Here is the altered version of the javascript. I took out the 3rd textarea, which is html_area, and all the red sections. But it then gave the error:

    Code:
    <!-- //
    
    conv_tbl = [
    
    63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    32, 33,8704, 1513,1505, 37, 83,8717, 65, 79, 8727, 1496, 44,8722, 58, 47,
    
    48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 46, 59, 60, 61, 62, 63,
    
    64, 1488, 1489, 1510, 1491, 69, 70, 1490, 1492, 73, 74, 1499, 1500, 1502, 1504, 1506,
    
    1508, 81, 1512, 1513, 1514, 85, 1493, 87, 1495, 1497, 90, 91, 92, 93, 94, 95,
    
    63, 97, 66, 1509, 68, 101, 102, 71, 72, 105, 106, 1498, 1500, 1501, 1503, 111,
    
    1507, 1511, 82, 8707, 84, 117, 118, 86, 88, 89, 1494, 123, 124, 125, 126, 63,
    
    63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    63, 978,8242,8804,8260,8734, 402,9827,9830,9829,9824,8596,8592,8593,8594,8595,
    
    63, 177,8243,8805, 215,8733,8706,8729, 247,8800,8801,8776,8230, 63, 63,8629,
    
    8501,8465,8476,8472,8855,8853,8709,8745,8746,8835,8839,8836,8834,8838,8712,8713,
    
    8736,8711, 174, 169,8482,8719,8730,8901, 172,8743,8744,8660,8656,8657,8658,8659,
    
    9674,9001, 174, 169,8482,8721, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
    
    63,9002,8747,8992, 63,8993, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63
    
    ];
    
     
    
    function convert(mc, unic_textarea)
    
    {
    
    unic = '';
    
     
    
    for (i = 0; i < mc.length; i++)
    
    {
    
         tbl_idx = mc.charCodeAt(i);
    
         code    = tbl_idx < conv_tbl.length ? conv_tbl[tbl_idx] : 63;
    
         unic    = unic + String.fromCharCode(code)
    
    }
    
     
    
    unic_textarea.value = unic;
    
    }
    
     
    
    function mc2unic()
    
    {
    
    mc = document.conv_form.mc_code.value;
    
    convert(mc, document.conv_form.unic_area);
    
    }
    
     
    
    // -->
    Compare bible texts (and other tools):
    TheWheelofGod

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After removing the space mentioned above I get no errors and the page works fine.


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
  •