Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 22nd, 2004, 06:03 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default Error: 'style.display' is null or not an object

Hello there

I'm having trouble with my navigation system and hoping someone can help me: it's a show all/hide all kind of drop down menu and I keep getting this error when I click on one of the menu items:

Error: 'style.display' is null or not an object - line 37

this is line 37

        if (id5.style.display == ""){

and this is the rest of the script:

<script language="JavaScript" type="text/JavaScript">
// Quick browser check !
ie4 = (document.all) ? true : false;

function showSubCats(targetId, id2, id3, id4, id5, id6){
    if (ie4){

        target = document.all(targetId);
        id2 = document.all(id2);
        id3 = document.all(id3);
        id4 = document.all(id4);
        id5 = document.all(id5);
        id6 = document.all(id6);

        if (target.style.display == "none"){
            target.style.display = "";
        } else {
            target.style.display = "none";
        }

        if (id2.style.display == ""){
            id2.style.display = "none";
        }

        if (id3.style.display == ""){
            id3.style.display = "none";
        }

        if (id4.style.display == ""){
            id4.style.display = "none";
        }

        if (id5.style.display == ""){
            id5.style.display = "none";
        }

        if (id6.style.display == ""){
            id6.style.display = "none";
        }

    }//End If
    else {
    document.location = "?NavID=" + targetId
    }
}

</script>

many thanks

Adam
 
Old April 22nd, 2004, 06:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

it's possible to view it in action at http://80.82.139.249/st-sar/navigation3.asp

thanks

Adam
 
Old April 22nd, 2004, 06:17 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It seems to work now, doesn't it?

Why do you make this a IE4 only page (or in fact, an IE only page as document.all works or all IE browsers)?? Hiding and displaying stuff like that can easily be done cross browser, so other standards compliant browsers can benefit from it as well.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Slow Love by Prince (Track 7 from the album: Sign O The Times (Disk 1))

 
Old April 22nd, 2004, 06:21 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Adam,

You have two rows with id="PR" and two with id="CU" in the page.

All ids in a page must be unique.

HTH,

Chris



 
Old April 22nd, 2004, 08:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

fantastic guys - thanks a million





Similar Threads
Thread Thread Starter Forum Replies Last Post
'style.display' null or not an object sheel331 Javascript 5 May 7th, 2008 11:41 AM
'style' is null or not an object earhear Beginning PHP 0 December 4th, 2007 04:22 AM
display Null or Not an object error kishy449 Classic ASP Professional 1 September 4th, 2007 01:21 PM
(axis) Return object in WS, with style="wrapped" u wakeup J2EE 0 July 17th, 2006 01:51 AM
Error: (variable) is null or not an object alisonchase JSP Basics 1 February 14th, 2005 07:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.