Link to home
Start Free TrialLog in
Avatar of JohanGLindberg
JohanGLindbergFlag for Finland

asked on

Invalid calling object in javascript, windows 7

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.



Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

f = document.getElementById();

might solve the problem.

Avatar of JohanGLindberg

ASKER

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?


html-code-with-scripts.htm
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.
ASKER CERTIFIED SOLUTION
Avatar of JohanGLindberg
JohanGLindberg
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.
Avatar of South Mod
All,
 
Following an 'Objection' by COBOLdinosaur (at https://www.experts-exchange.com/questions/27437200/11-Nov-11-09-Automated-Request-for-Review-Objection-to-Accept-Q-27423655.html) 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,
 
SouthMod
Community Support Moderator