Invalid calling object in javascript, windows 7

Posted on 2011-10-31
Last Modified: 2012-06-22
I have the following javascript function in a php file.

function selectAll() {
      f = document.getElementById;
      for (n = 0; n < <?=count($Report)?>; n++) {
            e = f("OF"+n);
            if (e)
                  e.checked = true;
      return false;

This works fine with Windows XP, Internet Explorer 8 or Chrome.

In Windows 7 with IE 9 the debugger stops at the line e = f("OF"+n);
The same issue comes up with Chrome.

The script is supposed to check all checkboxes found in a list.

It seems to be a cross browser problem related to Windows 7 since the script works fine on computers running Win XP.

Thanks for any help provided.

Question by:JohanGLindberg
    LVL 53

    Expert Comment

    f = document.getElementById();

    might solve the problem.


    Author Comment

    Added a new problem saying f is not a function and stopped working on Win XP + IE as well.

    I added the html code for the page. the scripts are called from the links at the end at
    VALINTA: kaikki (Selsectall).

    First I thought this must be an IE9 problem but the same problem exists in Chrome (where the scripts are working on XP) it might be related to Windows 7 as well?

    LVL 53

    Expert Comment

    I would be very surprised if that form is not broken with all of the non-form tags in it.  iframe is unpredictable, and there are all kinds od cross-browser issues with tables especially when you don't have a valid dtd to tell the browser how to parse.

    I would not even dream of trying to dig through that pile of code which you generated without linefeeds.  Two possible courses of action.  Cut down on the amount of stuff you are generating so you have a small enough data set to dig though the code.  Or, try setting some alerts to see  what is actually in the variables.  My gues is that Javasript cannot find the elements with the referenced ids even though they appear to be in the form.

    Accepted Solution

    IE:s compability-option solves it for ie9.

    Thanks for your time and comments!

    Author Comment

    I've requested that this question be closed as follows:

    Accepted answer: 0 points for JohanGLindberg's comment http:/Q_27423655.html#37099938

    for the following reason:

    The script works in compability mode even though it does not without.
    LVL 53

    Expert Comment

    If the questioner does not wish to proceed then the question should be deleted.  It ads zero value to the PAQ.  What he has done using compatibility mode is not a solution.  It is a hack that helps him and leaves 50% of visitors to the page with a problem.  All he did was tell IE 9 to pretend it is an old version of the browser. So any user who comes to the page using a modern browser including IE9 not in compatibility mode gets junk.  

    Anyone with the same problem who comes to EE looking for a solution would then get this non-answer to their problem.  Delete please.

    Expert Comment

    Following an 'Objection' by COBOLdinosaur (at to the intended closure of this question, it has been reviewed by at least one Moderator and is being closed as recommended by the Expert.
    At this point I am going to re-start the auto-close procedure.
    Thank you,
    Community Support Moderator

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    In a recent article here at Experts Exchange (, I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
    In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
    In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
    The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now