help!! (simple fix probably) multiple script imports not working

Discussion in 'JavaScript' started by js_learner, Apr 23, 2008.

  1. #1
    Hey,

    I am having some aggravating issues with importing script. I want to use methods from both of the scripts below. At the top of my main page, where I import the others, I have

    ------------------------------




    <?php session_start() ?>
    
    <html>
    
    <head>
    
    <title>CREATE CHARACTER (2)</title>
    //  -- This is a basic Asyncronistic xmlresponse handler
    [B]<script type="text/javascript" src="jsfiles/async1.js"></script> [/B]
    
     //  -- error here, for rqtools.js, saying, “[COLOR="Red"]Object expected[/COLOR]”
    [B]<script type="text/javascript" src="jsfiles/rqtools.js"></script[/B]>   
    <script type="text/javascript">
    …..
    Code (markup):
    if I include this line (which is a function in the second imported script)I get the above error (Object expected) pointing to the import of the rqtools.js. If I don’t include this line I get no error. I also made a test page to see if there was something wrong with the --rqtools.js-- file by including all the script in the head with no imports and using the method. It worked just fine. The code of the --rqtools-- is shown below. none of the variables/function names are reused anywhere on any pages of my code to prevent naming issues. each variable and function is unique in its naming in other words.


    var something_here=rqtoolsstripStr(“blablablablabla”);
    Code (markup):
    below is the rqtools.js





    function rqtoolsstripStr(check_string)
    
                {
    
                var char_arr_rqtools=new Array("~","1","2","3","4","5","6","7","8","9","0","-","q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m","Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M","!","@","#","_","?");
    
                var final_string_rqtools="";
    
                var cs_rqtools=check_string;
    
                var count_rqtools=cs_rqtools.length;
    
                for(var irq=0;irq<count_rqtools;irq++)
    
                {
    
                a_char_rqtools=cs_rqtools.charAt(irq);
    
                var count2_rqtools=0;
    
                while(count2_rqtools<char_arr_rqtools.length)
    
                            {
    
                            if(a_char_rqtools==char_arr_rqtools[count2_rqtools])
    
                                        {
    
                                        final_string_rqtools=final_string_rqtools+a_char_rqtools;
    
                                        }
    
                            count2_rqtools++;
    
                            }
    
                }
    
                return final_string_rqtools;
    
                }
    Code (markup):
    Thank you very much in advanced for your time in looking this over.
    Best Regards,
    Bryan
     
    js_learner, Apr 23, 2008 IP
  2. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    With Internet Explorer, keep in mind that the line number where the error occurred could be referring to any of the files you have included. It could also of course refer to the HTML page itself. To determine which file the error occurred in, you basically have to hunt.

    Additionally, the line number is usually off by 1 (although I can't remember which direction). So if it says line 76, check lines 75 and 77 of each possible offender.

    Start by doing a View Source of the HTML page as it appears in the browser (looking at the PHP source will tell you nothing). If there's no script there, start by looking at the JS files one at a time until you figure out the problem.

    Good luck!
     
    vpguy, Apr 23, 2008 IP
  3. js_learner

    js_learner Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    First I would like to thank vpguy for directing me back to my code. Thank you.

    The Answer---
    For some reason "rqtoolsstripStr(check_string)" would not take a string literal, it would only take a variable that represented a string.

    New Question---
    Why would this variable "rqtoolsstripStr(check_string)" not be able to take a string literal?

    Thanks again vpguy
    Best Regards
    Bryan
     
    js_learner, Apr 23, 2008 IP
  4. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You are probably calling the function incorrectly. For example, both of the following are invalid:

    <element onevent="rqtoolsstripStr("string literal"); return true;"></element>
    Code (markup):
    and
    setTimeout("rqtoolsstripStr("string literal");", 0);
    Code (markup):
    Note how the same type of quotes were used, which is not allowed. They should be rewritten as follows:

    <element onevent="rqtoolsstripStr('string literal'); return true;"></element>
    Code (markup):
    and
    setTimeout("rqtoolsstripStr('string literal');", 0);
    Code (markup):
    or
    setTimeout("rqtoolsstripStr(\"string literal\");", 0);
    Code (markup):
    There's another possibility as well, which is that the "straight" 'quotes' were inadvertenetly replaced with “curly” ‘quotes’. Only straight quotes can be used.
     
    vpguy, Apr 23, 2008 IP