[Javascript] How to disable by id in Mozilla -- working in IE 6, Netscape 7.1 and Mozilla 1.4 and Firebird 0.6.1 BUT NOT Opera 7

Guy Platt guy at webbnet.com
Thu Sep 25 04:57:24 CDT 2003


I managed to get pretty much what I wanted and learned a few things 
along the way. If anyone can help me get this working in Opera I'd be 
very happy.

In case anyone else was looking to do the same I'll post my findings.

Firstly the JS console in Mozilla Firebird was perfect for debugging the 
problems.

1)  the JS in Mozilla is case sensitive but NOT case sensitive in IE. 
(So the code worked in IE as it ignored my coding error).

2) Having fixed the coding I still couldn't get 'disabled' to work in 
Mozilla. However I changed the code to use style.display='none' and this 
worked fine. The added benefit of using style.display is that I can set 
this on the fieldset and all the form fields within the fieldset are 
either displayed or not.

Here is the code. My form is called 'registration' and the fieldset is 
'extrainfo'

if (document.getElementById('checkbox3').checked) {
    document.registration.extrainfo.style.display = 'block';
    }
else {
    document.registration.extrainfo.style.display = 'none';
    }


For Opera I tried .visibility = "visible" and .visibility = "hidden" but 
neither this nor the above code worked. Pity as the Opera help said that 
visibility was supported.

regards
 Guy






More information about the Javascript mailing list