[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

Hassan Schroeder hassan at webtuitive.com
Thu Sep 25 09:37:47 CDT 2003


Guy Platt wrote:

> 2) Having fixed the coding I still couldn't get 'disabled' to work in 
> Mozilla. 

? What version of Mozilla? The code below works fine in Moz 1.4
and IE 5.5 (both on Win) at least....

<script type="text/javascript">
function enable()
{
	var extraFields = document.getElementById('extraFields');
	extraFields.disabled = (extraFields.disabled)? false: true;
}
</script>

<form>
   <input type="checkbox" id="CheckBox3" onchange="enable();">
   <input type="text" id="extraFields"/>
</form>

Note: it doesn't work in Opera 7.11, but it's hard to get worked up
about that, given its history of poor JS support :-)

-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.






More information about the Javascript mailing list