Thread: Strange Problem

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    23

    Exclamation Strange Problem


    I'm having the weirdest problem, and it's only in my localhost: I cannot get javascript code that is loaded to another frame to fill in my listbox on my localhost server. When I move it to my development area, all is well. But on localhost? Forget it. It makes absolutely no sense.

    I've been told by one person that he thinks it's a bug with IE6. Whatever it is, it's a huge hassle to have to develop it on my machine and then move it to dev just to see if it works. Is there a work-around or anything that will force the javascript code to work the same on localhost as it does everywhere else? (We running everything on WebShere 5.1.2).

    Thanks.

    Pat
    Programmer at large
  2. #2
  3. Professional Lay-A-Bout
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Location
    Ann Arbor, Michigan
    Posts
    302
    Rep Power
    16
    Originally Posted by pflick
    I'm having the weirdest problem, and it's only in my localhost: I cannot get javascript code that is loaded to another frame to fill in my listbox on my localhost server. When I move it to my development area, all is well. But on localhost? Forget it. It makes absolutely no sense.

    I've been told by one person that he thinks it's a bug with IE6. Whatever it is, it's a huge hassle to have to develop it on my machine and then move it to dev just to see if it works. Is there a work-around or anything that will force the javascript code to work the same on localhost as it does everywhere else? (We running everything on WebShere 5.1.2).

    Thanks.

    Pat
    Well, I can see by your code that...
    Oh wait there isn't any.

    Anyhow, show us some code. I'd especially check your links to your scripts. It sounds like the interepeter is finding your scripts in your work area but not on your local host.

    Make sure that your server is pointing to correct folders as well. I know that's a given but you never know!
    Thomas

    Dogs and computers both do everything you tell them.
    But computers don't like their tummies rubbed.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    23
    Originally Posted by trumley
    Well, I can see by your code that...
    Oh wait there isn't any.

    Anyhow, show us some code. I'd especially check your links to your scripts. It sounds like the interepeter is finding your scripts in your work area but not on your local host.

    Make sure that your server is pointing to correct folders as well. I know that's a given but you never know!

    Okay, goof, here you go:

    Code:
    <script language="JavaScript">
         var root = top.topFrame;
         var t    = top.frames[0];
         //alert(t);
         var rt = new tm('root');
         var selectApp = -1;
    function safeJavaScriptIdentifier(id) {
        var safe = '';
        var c;
        for (var idIdx = 0; idIdx < id.length; idIdx++) {
            c = id.charAt(idIdx);
            if (
                (c >= 'A' && c <= 'Z')
                || (c >= 'a' && c <= 'z')
                || (idIdx > 0 && c >= '0' && c <= '9')
                || (c == '_')
            )
                safe += c;
            else
                safe += '_d' + c.charCodeAt(0) + '_';
        }
        return safe;
    }
    
    rt.addItem(new tmi("Region 1", "RGN1","RGN"));
    var rtRGN1 = new tm('rtRGN1');
    rt.items[0].sm(rtRGN1);
    rtRGN1.addItem(new tmi("Australia", "AUS","MKT"));
    rtRGN1.addItem(new tmi("Hong Kong", "HKG","MKT"));
    rtRGN1.addItem(new tmi("India", "IND","MKT"));
    rtRGN1.addItem(new tmi("Malaysia", "MYS","MKT"));
    rtRGN1.addItem(new tmi("New Zealand", "NZL","MKT"));
    rtRGN1.addItem(new tmi("Philippines", "PHL","MKT"));
    rtRGN1.addItem(new tmi("Singapore", "SGP","MKT"));
    rtRGN1.addItem(new tmi("Thailand", "THA","MKT"));
    rtRGN1.addItem(new tmi("Taiwan", "TWN","MKT"));
    
    rt.addItem(new tmi("Region 2", "RGN2","RGN"));
    var rtRGN2 = new tm('rtRGN2');
    rt.items[2].sm(rtRGN2);
    rtRGN2.addItem(new tmi("Belgium", "BEL","MKT"));
    rtRGN2.addItem(new tmi("Germany", "DEU","MKT"));
    rtRGN2.addItem(new tmi("Sweden", "SWE","MKT"));
    
        t.loadRegions();
        t.loadMarkets();
    
    
      if (selectApp > -1)
      {
         t.criteriaForm.RGN.disabled = false;
         t.criteriaForm.MKT.disabled = false;
         t.submitQuery();
      }
    </SCRIPT>
    I'd include more, but you know how it goes with companies. Hopefully you can figure out what's needed from there. RGN is the first listbox and MKT is the second. The really funny part is, if I hardcode in RGN1 in the first listbox, I have no issue getting all the codes for RGN1 into the second listbox (MKT). That makes a whole lot of sense, dontcha know...
    Programmer at large
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    23
    I figured it out. It was a problem with a function called getChildren() in another javascript file. It was set up to do this:

    function getChildren(item)
    {
    if (item == "dun") setItem(item);
    else setItem(findItem(item));
    if (getItem() != null) return getItem().items;
    }

    function findItem(item)
    {
    for (i = 0; i < sMenu.length; i++){
    if (subMenuList[i].id == item) return sMenu[i];
    }
    }
    You will notice that var item is a character string. Apparently, a non-patched older version of XP knew that we wanted the object named "dun" and returned it, but the patched version doesn't. What I did was change "setItem(item)" to "setItem(eval(item))" and that fixed it. I thought the problem was in the code I first sent. Nope. Just a simple thing in pre-existing code that I never would have figured out without several million alerts. Cheers!

    Pat

    Comments on this post

    • trumley agrees : congrats!
    Programmer at large

IMN logo majestic logo threadwatch logo seochat tools logo